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: StringWhere the curve files come from.
snapshot: SnapshotWhere and when the curve files were downloaded.
selection: StringThe 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
impl Catalog
Sourcepub fn bundled() -> Result<&'static Self, MotorError>
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.
Sourcepub fn from_json(text: &str) -> Result<Self, MotorError>
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.
Sourcepub fn bundled_named<'a>(
names: impl IntoIterator<Item = &'a str>,
) -> Result<Self, MotorError>
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).
Sourcepub fn bundled_with_ids<'a>(
ids: impl IntoIterator<Item = &'a str>,
) -> Result<Self, MotorError>
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.
Sourcepub fn bundled_snapshot() -> Result<Snapshot, MotorError>
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.
Sourcepub fn find<'a>(
&'a self,
name: &str,
) -> impl Iterator<Item = &'a CatalogMotor> + 'a
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 H128WorEstes 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:
D5is Quest’s D5, not the D5-P whose common name is D5. Matches of different makers all stay, whether by designation or common name:G80finds 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).
Sourcepub fn find_by_maker<'a>(
&'a self,
maker: &str,
name: &str,
) -> impl Iterator<Item = &'a CatalogMotor> + 'a
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.
Sourcepub fn find_for_design<'a>(
&'a self,
maker: &str,
name: &str,
digest: Option<&str>,
diameter_mm: Option<f64>,
) -> Vec<&'a CatalogMotor>
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
digestmaps 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_makergives is more than 1 mm fromdiameter_mmand 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.
Sourcepub fn find_for_bore<'a>(
&'a self,
name: &str,
bore_mm: f64,
) -> Vec<&'a CatalogMotor>
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.
Sourcepub fn selector(&self, motor: &CatalogMotor) -> String
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
impl Catalog
Sourcepub fn counts(&self) -> CatalogCounts
pub fn counts(&self) -> CatalogCounts
Its CatalogCounts.