Skip to main content

NetworkPackage

Struct NetworkPackage 

Source
#[non_exhaustive]
pub struct NetworkPackage {
Show 18 fields pub schema: String, pub schema_version: String, pub producer: Producer, pub package_id: Option<String>, pub created_at: Option<String>, pub model_kind: ModelKind, pub payload_schema: Option<String>, pub payload_schema_version: Option<String>, pub model: ModelPayload, pub operating_points: Option<OperatingPointSeries>, pub origin: Origin, pub sources: Vec<SourceDescriptor>, pub source_maps: Vec<SourceMapEntry>, pub diagnostics: Vec<StructuredDiagnostic>, pub validation: ValidationSummary, pub summary: ObjectSummary, pub lowering_history: Vec<LoweringRecord>, pub derived: DerivedMetadata,
}
Expand description

The compiler package: a versioned envelope around one IR payload plus the provenance, diagnostics, validation, and lowering history that make the artifact trustworthy. Serializes to .pio.json.

model_kind is stored explicitly and is authoritative; the payload is also self-describing (tagged by kind). NetworkPackage::kind_is_consistent asserts the two agree. Unknown future top-level fields are tolerated on read (ignored) so a newer producer’s package still deserializes here.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§schema: String

The schema URL identifying this package format.

§schema_version: String

The package schema version (semver).

§producer: Producer§package_id: Option<String>

Stable content id, e.g. "sha256:...". The scaffold leaves it None.

§created_at: Option<String>

RFC 3339 build timestamp. Left None by default for deterministic, round-trip-stable output; set explicitly when a timestamp is wanted.

§model_kind: ModelKind

Explicit model kind. Authoritative; never inferred from field presence.

§payload_schema: Option<String>

The declared schema URL for the payload family named by model_kind. None on packages written before the payload contract was declared.

§payload_schema_version: Option<String>

The declared payload schema version (semver), independent of the envelope schema_version: the envelope versions the package bookkeeping, this versions the network tables. A reader rejects a different major before computing on payload fields; None (legacy packages) is accepted.

§model: ModelPayload§operating_points: Option<OperatingPointSeries>

Replayable operating states over the static payload. The package constructors and setters omit empty series for static single state cases.

§origin: Origin§sources: Vec<SourceDescriptor>§source_maps: Vec<SourceMapEntry>§diagnostics: Vec<StructuredDiagnostic>§validation: ValidationSummary§summary: ObjectSummary§lowering_history: Vec<LoweringRecord>§derived: DerivedMetadata

Implementations§

Source§

impl NetworkPackage

Source

pub fn from_balanced(net: BalancedNetwork) -> Self

Wrap a balanced network. Origin is inferred from its source format: InMemory / Derived (normalized) / File (a parsed text format, recording whether source was retained; the path is not captured here). GOC3 sources also lift their time series into operating_points.

Source

pub fn from_multiconductor(net: MulticonductorNetwork) -> Self

Wrap a multiconductor network. Parse warnings are lifted into structured diagnostics, and defaulted fields are lifted into source maps with mapping_kind = defaulted, so the package surfaces that provenance even though those parser-side fields are not part of the IR payload.

Source

pub fn model_kind(&self) -> ModelKind

The explicit model kind.

Source

pub fn kind_is_consistent(&self) -> bool

Whether the explicit model_kind agrees with the payload variant. A reader should reject a package where this is false.

Source

pub fn as_balanced(&self) -> Option<&BalancedNetwork>

The balanced payload, if this package carries one.

Source

pub fn as_multiconductor(&self) -> Option<&MulticonductorNetwork>

The multiconductor payload, if this package carries one.

Source

pub fn operating_points(&self) -> Option<&OperatingPointSeries>

Replayable operating states over the static payload, when present.

Source

pub fn with_operating_points( self, operating_points: OperatingPointSeries, ) -> Self

Attach a format neutral operating point series to this package.

Source

pub fn set_operating_points(&mut self, operating_points: OperatingPointSeries)

Attach or replace operating points in place. Empty series are omitted.

Source

pub fn clear_operating_points(&mut self)

Remove operating points from this package.

Source

pub fn materialize_operating_point(&self, index: usize) -> Result<Self>

Materialize one operating point into a static package.

The returned package has the same metadata and model kind, with its payload updated for index, operating_points cleared, and sane validation recomputed for the updated payload.

Source

pub fn materialize_balanced_operating_point( &self, index: usize, ) -> Result<Option<BalancedNetwork>>

Materialize one operating point and return the balanced payload if this is a balanced package.

Source

pub fn materialize_multiconductor_operating_point( &self, index: usize, ) -> Result<Option<MulticonductorNetwork>>

Materialize one operating point and return the multiconductor payload if this is a multiconductor package.

Source

pub fn to_json(&self) -> Result<String>

Serialize to compact .pio.json.

Source

pub fn to_json_pretty(&self) -> Result<String>

Serialize to pretty .pio.json.

Source

pub fn from_json(text: &str) -> Result<Self>

Deserialize from .pio.json.

Source

pub fn supports_schema_version(version: &str) -> bool

Whether this reader accepts the envelope schema version.

The .pio.json compatibility contract is envelope scoped: unknown future top-level fields are ignored, additive same major versions load, and a different major version is rejected before payload use.

Source

pub fn with_origin(self, origin: Origin) -> Self

Source

pub fn with_package_id(self, id: impl Into<String>) -> Self

Source

pub fn with_created_at(self, created_at: impl Into<String>) -> Self

Source

pub fn with_sources(self, sources: Vec<SourceDescriptor>) -> Self

Source

pub fn with_source_maps(self, source_maps: Vec<SourceMapEntry>) -> Self

Source

pub fn push_lowering(&mut self, record: LoweringRecord)

Append a lowering record to the history.

Source

pub fn attach_normalized_solver_table_metadata(&mut self) -> Result<bool, Error>

Attach compact metadata for the normalized dense solver table lowering.

Returns Ok(false) for non-balanced packages. The full table rows stay outside the package payload; this records the pass name, row counts, units, dense identities, and source row provenance a compiler cache needs to validate external table artifacts.

Source

pub fn with_normalized_solver_table_metadata(self) -> Result<Self, Error>

Return a package with normalized solver table metadata attached.

Source

pub fn check_multiconductor_to_balanced_lowering( &self, ) -> Option<MulticonductorToBalancedReadiness>

Check whether this package’s multiconductor payload is ready for the explicit multiconductor to balanced lowering pass.

Source

pub fn lower_multiconductor_to_balanced( &self, options: MulticonductorToBalancedOptions, ) -> Result<Self, MulticonductorToBalancedError>

Explicitly lower a multiconductor package to a derived balanced package.

This method only accepts packages whose payload is ModelKind::Multiconductor. It does not mutate the input package.

Source

pub fn run_sane_validation(&mut self)

Run the package semantic validation profile and record its findings.

This pass leaves the payload untouched: it reports structural and semantic issues, but never repairs or rewrites the model. It does rewrite the package’s own diagnostics and validation, so it needs &mut self.

Trait Implementations§

Source§

impl Clone for NetworkPackage

Source§

fn clone(&self) -> NetworkPackage

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for NetworkPackage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for NetworkPackage

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for NetworkPackage

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,