Skip to main content

VehicleSchemaV1

Struct VehicleSchemaV1 

Source
pub struct VehicleSchemaV1 {
    pub fastsim_version: u32,
    pub powertrain: String,
    pub make: String,
    pub model: String,
    pub year: String,
    pub variant: String,
    pub revision: u32,
}
Expand description

Database organizational schema version 1 for the fastsim-vehicles repository.

Serializes to/from an 8-segment path-segment string, e.g. "v1/fastsim-3/conv/ford/fusion/2012/base/r1"

Segments in order:

  1. v1 — schema version marker
  2. fastsim-{N} — FASTSim version
  3. {powertrain} — powertrain type (e.g., “conv”, “hev”, “phev”, “bev”)
  4. {make} — vehicle make
  5. {model} — vehicle model (may include trim information)
  6. {year} — model year or year range
  7. {variant} — variant/feature configuration (e.g., “base”)
  8. r{N} — model revision/version for corrections

Fields§

§fastsim_version: u32

FASTSim version

§powertrain: String

Powertrain type (e.g., “conv”, “hev”, “phev”, “bev”)

§make: String

Vehicle make

§model: String

Vehicle model (may include trim information)

§year: String

Vehicle model year (or range of years)

§variant: String

Vehicle variant (describes what modeling features are active, etc.)

§revision: u32

Model revision/version for correcting model-level issues over time

Implementations§

Source§

impl VehicleSchemaV1

Source

pub fn new( fastsim_version: u32, powertrain: String, make: String, model: String, year: String, variant: String, revision: u32, ) -> Result<VehicleSchemaV1, VehicleSchemaV1Error>

Construct a schema from parsed field values, enforcing canonical identifiers.

§Errors

Returns an error if any of powertrain, make, model, year, or variant is not already in canonical identifier form (lowercase, ASCII, dashes and periods allowed).

Source

pub fn normalize_identifier(s: &str) -> String

Convert arbitrary text into the canonical identifier format used by schema paths. Examples:

  • "Outback XT""outback-xt"
  • "Model_3""model-3".
Source

pub fn validate_identifier(s: &str) -> bool

Validate that a string is a valid identifier for path segments.

Source

pub fn suggest_normalized_path(raw: &str) -> Option<(String, String)>

Suggests a normalized path when raw is structurally valid but not canonical.

Returns (current, suggested) when a suggestion differs from the current path.

Source

pub fn path_segments(&self) -> [String; 8]

Build the ordered path segments as an 8-element array (without file extension).

Returns in order:

  1. “v1” — schema version marker
  2. “fastsim-{N}” — FASTSim version
  3. powertrain — e.g., “conv”, “hev”, “phev”, “bev”
  4. make — e.g., “ford”, “tesla”
  5. model — e.g., “fusion”, “model-3”
  6. year — e.g., “2012”, “2020”
  7. variant — e.g., “base”, “trim-package”
  8. “r{N}” — revision/version number
Source

pub fn build_filepath<P>(&self, base_dir: P, extension: &str) -> PathBuf
where P: AsRef<Path>,

Build a local file path by joining the schema’s path-segment string with a base directory and extension.

Example: base_dir/v1/fastsim-3/conv/ford/fusion/2012/base/r1.yaml

Source

pub fn build_url(&self, base_url: Option<&str>, extension: &str) -> String

Build a remote URL by joining the schema’s path-segment string with a base URL and extension.

If base_url is None, uses the default GitHub raw content URL. Example: https://raw.githubusercontent.com/.../v1/fastsim-3/conv/ford/fusion/2012/base/r1.yaml

Trait Implementations§

Source§

impl Clone for VehicleSchemaV1

Source§

fn clone(&self) -> VehicleSchemaV1

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 VehicleSchemaV1

Source§

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

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

impl<'de> Deserialize<'de> for VehicleSchemaV1

Source§

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

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

impl Display for VehicleSchemaV1

Source§

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

Display the schema as its path-segment string representation.

Formats as: v1/fastsim-{N}/{powertrain}/{make}/{model}/{year}/{variant}/r{N}

Source§

impl FromStr for VehicleSchemaV1

Source§

fn from_str( s: &str, ) -> Result<VehicleSchemaV1, <VehicleSchemaV1 as FromStr>::Err>

Parse a schema from its path-segment string representation.

Expected format (8 segments): v1/fastsim-{N}/{powertrain}/{make}/{model}/{year}/{variant}/r{N}

§Errors

This parser has two validation phases and may fail in either phase:

  • Structural parsing (parse_structural): wrong segment count, wrong required prefixes, or non-numeric version fields.
  • Canonical identifier validation (new): any of powertrain, make, model, year, or variant is not already a canonical identifier.
Source§

type Err = VehicleSchemaV1Error

The associated error which can be returned from parsing.
Source§

impl PartialEq for VehicleSchemaV1

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for VehicleSchemaV1

Source§

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

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

impl StructuralPartialEq for VehicleSchemaV1

Source§

impl TryFrom<String> for VehicleSchemaV1

Source§

type Error = VehicleSchemaV1Error

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

fn try_from( s: String, ) -> Result<VehicleSchemaV1, <VehicleSchemaV1 as TryFrom<String>>::Error>

Performs the conversion.

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.