Skip to main content

DesignFile

Struct DesignFile 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§format: Format

Always hpr-design.

§version: Version

The format’s version, major.minor.

§provenance: Provenance

Which program wrote the document, and from what.

§rocket: Rocket

The rocket: its stages and their parts, with every configuration that flies.

§motors: Motors

Every motor configuration, flown or not, with why one is not.

§recovery: Recovery

When each parachute and streamer opens and each stage separates.

§simulations: Vec<StoredSimulation>

The simulations the source file stored, with their conditions and results.

§extensions: Extensions

What 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

Source

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.

Source

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.

Source

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.

Source

pub fn design(&self) -> Design

The design the document holds, as hpr_io::ork would have read it.

Source

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.

Source

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

Source§

fn clone(&self) -> DesignFile

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DesignFile

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for DesignFile

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl JsonSchema for DesignFile

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl PartialEq for DesignFile

Source§

fn eq(&self, other: &DesignFile) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for DesignFile

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for DesignFile

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.