Skip to main content

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 lowering;
40pub mod model;
41pub mod operating;
42pub mod package;
43pub mod provenance;
44pub mod study;
45pub mod summary;
46pub mod validation;
47
48pub use diagnostics::{DiagnosticCode, DiagnosticSeverity, DiagnosticStage, StructuredDiagnostic};
49pub use lowering::{
50    LoweringRecord, MulticonductorToBalancedError, MulticonductorToBalancedLowering,
51    MulticonductorToBalancedOptions, MulticonductorToBalancedReadiness,
52    SequenceTransformConvention, check_multiconductor_to_balanced_lowering,
53    lower_multiconductor_to_balanced,
54};
55pub use model::{ModelKind, ModelPayload};
56pub use operating::{ElementRef, ElementUpdate, OperatingPoint, OperatingPointSeries, TimeAxis};
57pub use package::{
58    DerivedMetadata, NetworkPackage, NormalizedSolverTableMetadata, NormalizedSolverTableRowCounts,
59    NormalizedSolverTableSourceRows, PIO_PACKAGE_SCHEMA_URL, PIO_PACKAGE_SCHEMA_VERSION,
60    PIO_PAYLOAD_BALANCED_SCHEMA_URL, PIO_PAYLOAD_BALANCED_SCHEMA_VERSION,
61    PIO_PAYLOAD_MULTICONDUCTOR_SCHEMA_URL, PIO_PAYLOAD_MULTICONDUCTOR_SCHEMA_VERSION,
62    READ_GRIDFM_FIDELITY_WARNING, READ_TRANSMISSION_PARSE_WARNING, ensure_payload_uids,
63};
64pub use provenance::{
65    Confidence, MappingKind, Origin, Producer, SourceDescriptor, SourceMapEntry, SourceRef,
66};
67pub use study::{StudyBlock, StudyCommit, StudyEdit};
68pub use summary::{ObjectSummary, ObjectTopology, ObjectUnits};
69pub use validation::{ValidationCounts, ValidationPass, ValidationStatus, ValidationSummary};