pub fn parse(input: impl IntoSource) -> Result<PioModule<PioValue>, Error>Expand description
Parse one source into a compiled module of whichever built in family
claims it. Balanced network formats produce
PioValue::BalancedNetwork; network only distribution formats (OpenDSS
.dss, PMD ENGINEERING JSON, and BMOPF JSON) produce
PioValue::MulticonductorNetwork. A source that defines a particular
calculation produces that calculation’s value. One DOE GO Challenge 3
problem data file produces PioValue::AcScucInstance. One source that
contains a problem data file and its matching solution data file produces
PioValue::AcScucSolution; a solution data file alone is rejected because
its row identities and time axis come from the problem. DeepMind OPFData
JSON, which explicitly represents a solved AC OPF, produces
PioValue::AcOpfSolution. The parser’s findings are the module’s
diagnostics, and the module keeps the original input, so writing the same
format again returns the original file content.
The input is a file or directory name, content already in memory, or a
powerio_core::Source carrying named buffers or a widened acquisition
root. parse_with_options selects the parser explicitly. Content in
memory carries the name powerio_core::MEMORY_SOURCE_NAME, which
identifies no format, so a format detected from a file extension rather
than from the document itself is either declared through the options or
named through powerio_core::Source::from_memory.
The family comes from the input’s declared format when one was selected,
and otherwise from the name and content: a .dss extension routes to the
distribution parser, a .json document routes by its top level markers
(format::routing::classify_json_text), a name with no recognized
extension whose content opens a JSON document (an in-memory source has no
extension) routes the same way, and every other name routes to
the balanced network hub, whose own detection and refusals apply.
PowerIO IR is not a grid exchange format: parse refuses it and
deserialize reads the current PowerIO IR document.
§Errors
The routed family’s failure, carrying its findings and the retained source.