powerio_pkg/lib.rs
1//! `.pio.json` package metadata and model payloads.
2//!
3//! PowerIO keeps two static network model families as separate types:
4//!
5//! - [`powerio::BalancedNetwork`], the scalar positive sequence transmission
6//! model;
7//! - [`powerio_dist::MulticonductorNetwork`], the wire coordinate distribution
8//! model.
9//!
10//! A [`NetworkPackage`] stores one payload with an explicit [`ModelKind`],
11//! producer and origin metadata, source maps, diagnostics, validation results,
12//! and lowering history. Optional operating points replay independent states;
13//! optional study commits apply cumulative edits. GOC3 packages use operating
14//! points for the source time series: the payload holds one static interval, and
15//! [`NetworkPackage::materialize_operating_point`] derives another static
16//! package from a selected period. It serializes to `.pio.json`. See
17//! `docs/src/compiler-ir.md` for the architecture and
18//! `docs/src/pio-json-schema.md` for the field reference.
19//!
20//! The package always carries [`NetworkPackage::model_kind`] explicitly; a
21//! reader must never infer whether the payload is balanced or multiconductor
22//! from which field is present. [`NetworkPackage::kind_is_consistent`] asserts
23//! the explicit kind agrees with the payload variant.
24//!
25//! ```
26//! use powerio_pkg::{NetworkPackage, ModelKind};
27//!
28//! let net = powerio::BalancedNetwork::in_memory("demo", 100.0, vec![], vec![]);
29//! let pkg = NetworkPackage::from_balanced(net);
30//! assert_eq!(pkg.model_kind(), ModelKind::Balanced);
31//! assert!(pkg.kind_is_consistent());
32//! let json = pkg.to_json_pretty().unwrap();
33//! let back = NetworkPackage::from_json(&json).unwrap();
34//! assert_eq!(back.model_kind(), ModelKind::Balanced);
35//! ```
36//!
37
38pub mod diagnostics;
39pub mod geo;
40pub mod lowering;
41pub mod model;
42pub mod operating;
43pub mod package;
44pub mod provenance;
45pub mod study;
46pub mod summary;
47pub mod validation;
48
49pub use diagnostics::{DiagnosticCode, DiagnosticSeverity, DiagnosticStage, StructuredDiagnostic};
50pub use geo::{apply_dist_geo_layer, dist_geo_layer};
51pub use lowering::{
52 LoweringRecord, MulticonductorToBalancedError, MulticonductorToBalancedLowering,
53 MulticonductorToBalancedOptions, MulticonductorToBalancedReadiness,
54 SequenceTransformConvention, check_multiconductor_to_balanced_lowering,
55 lower_multiconductor_to_balanced,
56};
57pub use model::{ModelKind, ModelPayload};
58pub use operating::{ElementRef, ElementUpdate, OperatingPoint, OperatingPointSeries, TimeAxis};
59pub use package::{
60 DerivedMetadata, NetworkPackage, NormalizedSolverTableMetadata, NormalizedSolverTableRowCounts,
61 NormalizedSolverTableSourceRows, PIO_PACKAGE_SCHEMA_URL, PIO_PACKAGE_SCHEMA_VERSION,
62 PIO_PAYLOAD_BALANCED_SCHEMA_URL, PIO_PAYLOAD_BALANCED_SCHEMA_VERSION,
63 PIO_PAYLOAD_MULTICONDUCTOR_SCHEMA_URL, PIO_PAYLOAD_MULTICONDUCTOR_SCHEMA_VERSION,
64 READ_GRIDFM_FIDELITY_WARNING, READ_TRANSMISSION_PARSE_WARNING, ensure_payload_uids,
65};
66pub use provenance::{
67 Confidence, MappingKind, Origin, Producer, SourceDescriptor, SourceMapEntry, SourceRef,
68};
69pub use study::{StudyBlock, StudyCommit, StudyEdit};
70pub use summary::{ObjectSummary, ObjectTopology, ObjectUnits};
71pub use validation::{ValidationCounts, ValidationPass, ValidationStatus, ValidationSummary};