Skip to main content

Catalog

Struct Catalog 

Source
pub struct Catalog {
    pub source: String,
    pub snapshot: Snapshot,
    pub selection: String,
    pub motors: Vec<CatalogMotor>,
    pub left_out: Vec<LeftOut>,
}
Expand description

A motor catalog.

Fields§

§source: String

Where the curve files come from.

§snapshot: Snapshot

Where and when the curve files were downloaded.

§selection: String

The rule that chose the curves.

§motors: Vec<CatalogMotor>

The motors.

§left_out: Vec<LeftOut>

The snapshot’s files the index leaves out, each with its reason.

Implementations§

Source§

impl Catalog

Source

pub fn bundled() -> Result<&'static Self, MotorError>

The catalog compiled into this crate, which hpr motors, hpr sim --motor and a design’s motors are looked up in: ThrustCurve.org’s whole solid catalog (M5.7), every solid motor in the snapshot and every file but a restricted one, each with its stored check, and each file left out with its reason (ADR-301).

§Errors

MotorError::Catalog if the index doesn’t deserialize, which a test rules out.

Source

pub fn from_json(text: &str) -> Result<Self, MotorError>

Reads a catalog index.

§Errors

MotorError::Catalog if the text isn’t a catalog index, or a curve’s stored CurveCheck::passes isn’t what its stored figures give against its motor’s stated ones: the flag ranks the files, so one that says a failing file passes would fly it silently.

Source

pub fn bundled_named<'a>( names: impl IntoIterator<Item = &'a str>, ) -> Result<Self, MotorError>

The bundled catalog holding only the motors name lookups can find: those whose designation or common name is one of names, ignoring ASCII case, spaces and hyphens.

Catalog::find_for_design answers each of names here as it does in Catalog::bundled, which reading a design needs. Nothing else is promised: a listing of this catalog is not the catalog’s. It isn’t shared either: each call reads the index again.

§Errors

As Catalog::from_json, for the motors kept (the bundled index’s tests read them all).

Source

pub fn bundled_with_ids<'a>( ids: impl IntoIterator<Item = &'a str>, ) -> Result<Self, MotorError>

The bundled catalog holding only the motors with one of ids, as Catalog::bundled_named holds those of its names.

§Errors

As Catalog::from_json, for the motors kept.

Source

pub fn bundled_snapshot() -> Result<Snapshot, MotorError>

The bundled catalog’s Snapshot, without reading its motors: every hpr sim states the catalog’s date, whether a motor came from it or not.

§Errors

As Catalog::bundled, when the index’s head can’t be read alone and the whole is read.

Source

pub fn find<'a>( &'a self, name: &str, ) -> impl Iterator<Item = &'a CatalogMotor> + 'a

The motors name names (ADR-302): those whose designation or common name matches it, ignoring ASCII case, spaces and hyphens (j760, 1266J760-19A, K 940).

  • A name may start with a maker, its full name or short one and a space, such as AeroTech H128W or Estes Industries C6: then only that maker’s motors match.
  • Of one maker’s matches, a motor whose designation is the name is the one it names: D5 is Quest’s D5, not the D5-P whose common name is D5. Matches of different makers all stay, whether by designation or common name: G80 finds Roadrunner’s and Estes’ G80 and AeroTech’s G80T, so a caller that wants one refuses it as ambiguous rather than flying a maker the name didn’t say. Each maker’s short name and designation names one alone, as no maker has two motors of one designation (a test holds it).
Source

pub fn find_by_maker<'a>( &'a self, maker: &str, name: &str, ) -> impl Iterator<Item = &'a CatalogMotor> + 'a

As Catalog::find, among the motors of the maker maker names, by its full or short name with only its ASCII letters and digits compared, ignoring case (Cesaroni Technology Inc. is Cesaroni Technology’s, AEROTECH AeroTech’s): the lookup a design file’s motor, which names its maker apart, takes.

Source

pub fn find_for_design<'a>( &'a self, maker: &str, name: &str, digest: Option<&str>, diameter_mm: Option<f64>, ) -> Vec<&'a CatalogMotor>

As Catalog::find_by_maker, for a design file’s motor, which may also give its curve’s digest and its case’s diameter_mm. Cesaroni’s 54 mm 1016J360-15A has the common name J360, which is the designation of a 38 mm Cesaroni motor; a file that saved the first as J360 must not fly the second, about 20% short on impulse:

  • where digest maps to a bundled file (crate::openrocket_curves::file_for) of exactly one motor the name matches by designation or common name, that motor alone;
  • else, where every motor Catalog::find_by_maker gives is more than 1 mm from diameter_mm and another the name matches is within it, every match, so the caller refuses the motor as ambiguous rather than flying a case the design doesn’t hold.
Source

pub fn find_for_bore<'a>( &'a self, name: &str, bore_mm: f64, ) -> Vec<&'a CatalogMotor>

As Catalog::find, for a motor named by hand to go into a mount whose bore is bore_mm across. It follows the diameter guard of ADR-302 §1, on looking a motor up by name, which Catalog::find_for_design applies to a design file’s motor against the file’s case diameter; here it is measured against the mount’s bore. Where another motor the name matches, by designation or common name, fits the bore more closely by more than BORE_TOLERANCE_MM than every motor Catalog::find gives (or where none of those fits and another does), every match, so the caller refuses the name as ambiguous; else what Catalog::find gives. A motor fits when it is no wider than the bore and the tolerance; the closer fit leaves less room around it. So J360 in a 54 mm mount names both Cesaroni’s 38 mm J360 and its 54 mm 1016J360-15A, and in a 38 mm mount the J360 alone.

Source

pub fn selector(&self, motor: &CatalogMotor) -> String

The name that selects motor alone through Catalog::find: its designation where that finds it alone, else its maker’s short name and its designation, such as Estes C6.

Source§

impl Catalog

Trait Implementations§

Source§

impl Clone for Catalog

Source§

fn clone(&self) -> Catalog

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 Catalog

Source§

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

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

impl<'de> Deserialize<'de> for Catalog

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 PartialEq for Catalog

Source§

fn eq(&self, other: &Catalog) -> 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 Catalog

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 Catalog

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
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.

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.