#[non_exhaustive]pub struct DesignFile {
pub format: Format,
pub version: Version,
pub provenance: Provenance,
pub rocket: Rocket,
pub motors: Motors,
pub recovery: Recovery,
pub simulations: Vec<StoredSimulation>,
pub extensions: Extensions,
pub source_files: Vec<SourceFile>,
}Expand description
A design as one document of the hpr design format.
The keys are written in this order. The design’s own parts are those of hpr_io::ork::Design,
whose documentation says what each holds.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.format: FormatAlways hpr-design.
version: VersionThe format’s version, major.minor.
provenance: ProvenanceWhich program wrote the document, and from what.
rocket: RocketThe rocket: its stages and their parts, with every configuration that flies.
motors: MotorsEvery motor configuration, flown or not, with why one is not.
recovery: RecoveryWhen each parachute and streamer opens and each stage separates.
simulations: Vec<StoredSimulation>The simulations the source file stored, with their conditions and results.
extensions: ExtensionsWhat the source file holds that hpr does not model, by namespace, kept for writing it back.
source_files: Vec<SourceFile>The source file’s other files, in the order it held them: a .ork archive’s entries
besides the design, such as embedded thrust curves and decal images. Version 0.1 called
them attachments.
Implementations§
Source§impl DesignFile
impl DesignFile
Sourcepub fn new(
design: Design,
provenance: Provenance,
source_files: &[Attachment],
) -> Self
pub fn new( design: Design, provenance: Provenance, source_files: &[Attachment], ) -> Self
The document of design, with its provenance and the source file’s other files.
source_files must hold each thrust curve the design’s motors name as embedded
(Curve::Embedded): the file’s own
OrkFile::attachments do. Without one, to_json
refuses the document.
A design read from a .ork should name, in its provenance’s
Source::airframe_not_as_written, why the file’s airframe was not read exactly as written,
if it wasn’t: without it, a program flies another motor in a rocket its .ork refuses.
DesignFile::from_ork sets it.
Sourcepub fn from_ork(bytes: &[u8]) -> Result<Imported<Self>, OrkError>
pub fn from_ork(bytes: &[u8]) -> Result<Imported<Self>, OrkError>
Reads a .ork file’s bytes (zip, gzip or raw XML) into a document whose provenance names
this program, the file’s SHA-256 and why its airframe was not read exactly as written, if
it wasn’t, with the reader’s warnings.
The design is hpr_io::ork::design’s: a motor configuration flies with the curve the
file itself holds.
§Errors
OrkError when the bytes are not a .ork hpr can read.
Sourcepub fn stamped(self) -> Self
pub fn stamped(self) -> Self
The document as this program writes it again: its provenance names this build, and
where the design came from is kept exactly as read (Provenance::rewritten). A
conversion writes a new file, so the program that wrote it is this one; the design’s
source doesn’t change.
Sourcepub fn design(&self) -> Design
pub fn design(&self) -> Design
The design the document holds, as hpr_io::ork would have read it.
Sourcepub fn source_files(&self) -> Result<Vec<Attachment>, FormatError>
pub fn source_files(&self) -> Result<Vec<Attachment>, FormatError>
The source file’s other files, as bytes.
§Errors
FormatError::Invalid when a file’s base64 does not decode; from_json refuses such a
document, so only one built in code can hold one.
Sourcepub fn to_ork(&self) -> Result<Imported<Vec<u8>>, FormatError>
pub fn to_ork(&self) -> Result<Imported<Vec<u8>>, FormatError>
The design written as a .ork (hpr_io::ork::export::write) with the source file’s
other files, so it is the .ork hpr writes from the source file itself.
§Errors
FormatError::Invalid for a source file that does not decode, and
FormatError::Ork when the archive cannot be written.
Trait Implementations§
Source§impl Clone for DesignFile
impl Clone for DesignFile
Source§fn clone(&self) -> DesignFile
fn clone(&self) -> DesignFile
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DesignFile
impl Debug for DesignFile
Source§impl<'de> Deserialize<'de> for DesignFile
impl<'de> Deserialize<'de> for DesignFile
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for DesignFile
impl JsonSchema for DesignFile
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for DesignFile
impl PartialEq for DesignFile
Source§fn eq(&self, other: &DesignFile) -> bool
fn eq(&self, other: &DesignFile) -> bool
self and other values to be equal, and is used by ==.