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:
v1— schema version markerfastsim-{N}— FASTSim version{powertrain}— powertrain type (e.g., “conv”, “hev”, “phev”, “bev”){make}— vehicle make{model}— vehicle model (may include trim information){year}— model year or year range{variant}— variant/feature configuration (e.g., “base”)r{N}— model revision/version for corrections
Fields§
§fastsim_version: u32FASTSim version
powertrain: StringPowertrain type (e.g., “conv”, “hev”, “phev”, “bev”)
make: StringVehicle make
model: StringVehicle model (may include trim information)
year: StringVehicle model year (or range of years)
variant: StringVehicle variant (describes what modeling features are active, etc.)
revision: u32Model revision/version for correcting model-level issues over time
Implementations§
Source§impl VehicleSchemaV1
impl VehicleSchemaV1
Sourcepub fn new(
fastsim_version: u32,
powertrain: String,
make: String,
model: String,
year: String,
variant: String,
revision: u32,
) -> Result<VehicleSchemaV1, VehicleSchemaV1Error>
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).
Sourcepub fn normalize_identifier(s: &str) -> String
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".
Sourcepub fn validate_identifier(s: &str) -> bool
pub fn validate_identifier(s: &str) -> bool
Validate that a string is a valid identifier for path segments.
Sourcepub fn suggest_normalized_path(raw: &str) -> Option<(String, String)>
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.
Sourcepub fn path_segments(&self) -> [String; 8]
pub fn path_segments(&self) -> [String; 8]
Build the ordered path segments as an 8-element array (without file extension).
Returns in order:
- “v1” — schema version marker
- “fastsim-{N}” — FASTSim version
- powertrain — e.g., “conv”, “hev”, “phev”, “bev”
- make — e.g., “ford”, “tesla”
- model — e.g., “fusion”, “model-3”
- year — e.g., “2012”, “2020”
- variant — e.g., “base”, “trim-package”
- “r{N}” — revision/version number
Sourcepub fn build_filepath<P>(&self, base_dir: P, extension: &str) -> PathBuf
pub fn build_filepath<P>(&self, base_dir: P, extension: &str) -> PathBuf
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
Sourcepub fn build_url(&self, base_url: Option<&str>, extension: &str) -> String
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
impl Clone for VehicleSchemaV1
Source§fn clone(&self) -> VehicleSchemaV1
fn clone(&self) -> VehicleSchemaV1
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 VehicleSchemaV1
impl Debug for VehicleSchemaV1
Source§impl<'de> Deserialize<'de> for VehicleSchemaV1
impl<'de> Deserialize<'de> for VehicleSchemaV1
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<VehicleSchemaV1, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<VehicleSchemaV1, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Display for VehicleSchemaV1
impl Display for VehicleSchemaV1
Source§impl FromStr for VehicleSchemaV1
impl FromStr for VehicleSchemaV1
Source§fn from_str(
s: &str,
) -> Result<VehicleSchemaV1, <VehicleSchemaV1 as FromStr>::Err>
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 ofpowertrain,make,model,year, orvariantis not already a canonical identifier.