Expand description
Script loader: parse molpack’s .inp input format and turn it into
a configured Molpack plus a list of
Targets.
Two front-end shapes are supported:
-
Native (feature
io) — [Script::build] reads template files via molrs-io and returns a ready-to-run [BuildResult]:ⓘuse std::path::Path; use molpack::script; let src = std::fs::read_to_string("mixture.inp")?; let script = script::parse(&src)?; let built = script.build(Path::new("."))?; let frame = built.packer.pack(&built.targets, built.nloop)?; script::write_frame(&built.output, &frame)?; -
Embedding hosts (any feature set) —
Script::lowerreturns aScriptPlanwith file paths resolved but unread. The caller loads eachStructurePlan::filepathwith its own frame loader, builds aTarget, and stamps restraints viaStructurePlan::apply. This is what the PyO3 wheel uses, so it does not have to statically link molrs-io.
Parsing, lowering, and I/O are kept separate so embedders can
intercept any stage — e.g. mutate the parsed Script before
lower, attach a custom Handler to the packer,
or route output through a different writer.
Structs§
- Atom
Group - One
atoms … end atomssub-block. - PbcSpec
- Periodic-boundary box declared at the top level via
pbc. - Script
- A fully parsed packing script.
- Script
Plan - Loader-agnostic lowering of a
Script: paths resolved, restraints kept as parsedRestraintSpecs, no filesystem access yet. - Structure
- One
structure … end structureblock. - Structure
Plan - Per-structure lowering: resolved file path plus the restraints / pose
hints that apply to its
Target.
Enums§
- Restraint
Spec - AtomRestraint as it appears in the script, before being mapped to a
concrete
AtomRestraintimplementation. - Script
Error - Errors produced by the script module — from parsing, file loading, or
the downstream
pack()call invoked by a script-driven run.
Functions§
- parse
- Parse a script from its textual source.