SerdeAPI

Trait SerdeAPI 

Source
pub trait SerdeAPI:
    Serialize
    + for<'a> Deserialize<'a>
    + Init {
    const ACCEPTED_BYTE_FORMATS: &'static [&'static str] = _;
    const ACCEPTED_STR_FORMATS: &'static [&'static str] = _;
    const RESOURCES_DIR: &'static Dir<'_> = _;
    const RESOURCES_SUBDIR: &'static str = "";
Show 16 methods // Provided methods fn from_resource<P: AsRef<Path>>( filepath: P, skip_init: bool, ) -> Result<Self, Error> { ... } fn list_resources() -> Result<Vec<PathBuf>, Error> { ... } fn to_file<P: AsRef<Path>>(&self, filepath: P) -> Result<(), Error> { ... } fn from_file<P: AsRef<Path>>( filepath: P, skip_init: bool, ) -> Result<Self, Error> { ... } fn to_writer<W: Write>(&self, wtr: W, format: &str) -> Result<(), Error> { ... } fn from_reader<R: Read>( rdr: &mut R, format: &str, skip_init: bool, ) -> Result<Self, Error> { ... } fn to_str(&self, format: &str) -> Result<String> { ... } fn from_str<S: AsRef<str>>( contents: S, format: &str, skip_init: bool, ) -> Result<Self> { ... } fn to_json(&self) -> Result<String> { ... } fn from_json<S: AsRef<str>>(json_str: S, skip_init: bool) -> Result<Self> { ... } fn to_msg_pack(&self) -> Result<Vec<u8>> { ... } fn from_msg_pack(msg_pack: &[u8], skip_init: bool) -> Result<Self> { ... } fn to_toml(&self) -> Result<String> { ... } fn from_toml<S: AsRef<str>>(toml_str: S, skip_init: bool) -> Result<Self> { ... } fn to_yaml(&self) -> Result<String> { ... } fn from_yaml<S: AsRef<str>>(yaml_str: S, skip_init: bool) -> Result<Self> { ... }
}

Provided Associated Constants§

Source

const ACCEPTED_BYTE_FORMATS: &'static [&'static str] = _

Source

const ACCEPTED_STR_FORMATS: &'static [&'static str] = _

Source

const RESOURCES_DIR: &'static Dir<'_> = _

Source

const RESOURCES_SUBDIR: &'static str = ""

Provided Methods§

Source

fn from_resource<P: AsRef<Path>>( filepath: P, skip_init: bool, ) -> Result<Self, Error>

Read (deserialize) an object from a resource file packaged with the fastsim-core crate

§Arguments:
  • filepath - Filepath, relative to the top of the resources folder (excluding any relevant prefix), from which to read the object
Source

fn list_resources() -> Result<Vec<PathBuf>, Error>

List the available resources in the resources directory

RETURNS: a vector of strings for resources that can be loaded

Source

fn to_file<P: AsRef<Path>>(&self, filepath: P) -> Result<(), Error>

Write (serialize) an object to a file. Supported file extensions are listed in ACCEPTED_BYTE_FORMATS. Creates a new file if it does not already exist, otherwise truncates the existing file.

§Arguments
  • filepath - The filepath at which to write the object
Source

fn from_file<P: AsRef<Path>>( filepath: P, skip_init: bool, ) -> Result<Self, Error>

Read (deserialize) an object from a file. Supported file extensions are listed in ACCEPTED_BYTE_FORMATS.

§Arguments:
  • filepath: The filepath from which to read the object
Source

fn to_writer<W: Write>(&self, wtr: W, format: &str) -> Result<(), Error>

Write (serialize) an object into anything that implements std::io::Write

§Arguments:
  • wtr - The writer into which to write object data
  • format - The target format, any of those listed in ACCEPTED_BYTE_FORMATS
Source

fn from_reader<R: Read>( rdr: &mut R, format: &str, skip_init: bool, ) -> Result<Self, Error>

Deserialize an object from anything that implements std::io::Read

§Arguments:
  • rdr - The reader from which to read object data
  • format - The source format, any of those listed in ACCEPTED_BYTE_FORMATS
Source

fn to_str(&self, format: &str) -> Result<String>

Write (serialize) an object into a string

§Arguments:
Source

fn from_str<S: AsRef<str>>( contents: S, format: &str, skip_init: bool, ) -> Result<Self>

Read (deserialize) an object from a string

§Arguments:
  • contents - The string containing the object data
  • format - The source format, any of those listed in ACCEPTED_STR_FORMATS
Source

fn to_json(&self) -> Result<String>

Write (serialize) an object to a JSON string

Source

fn from_json<S: AsRef<str>>(json_str: S, skip_init: bool) -> Result<Self>

Read (deserialize) an object from a JSON string

§Arguments
  • json_str - JSON-formatted string to deserialize from
Source

fn to_msg_pack(&self) -> Result<Vec<u8>>

Write (serialize) an object to a message pack

Source

fn from_msg_pack(msg_pack: &[u8], skip_init: bool) -> Result<Self>

Read (deserialize) an object from a message pack

§Arguments
  • msg_pack - message pack object
Source

fn to_toml(&self) -> Result<String>

Write (serialize) an object to a TOML string

Source

fn from_toml<S: AsRef<str>>(toml_str: S, skip_init: bool) -> Result<Self>

Read (deserialize) an object from a TOML string

§Arguments
  • toml_str - TOML-formatted string to deserialize from
Source

fn to_yaml(&self) -> Result<String>

Write (serialize) an object to a YAML string

Source

fn from_yaml<S: AsRef<str>>(yaml_str: S, skip_init: bool) -> Result<Self>

Read (deserialize) an object from a YAML string

§Arguments
  • yaml_str - YAML-formatted string to deserialize from

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<D> SerdeAPI for InterpolatorEnum<D>

Source§

const RESOURCES_SUBDIR: &'static str = "interpolators"

Source§

impl<T> SerdeAPI for Extrapolate<T>
where T: Serialize + for<'de> Deserialize<'de>,

Source§

impl<T: SerdeAPI> SerdeAPI for Vec<T>

Implementors§

Source§

impl SerdeAPI for TraceMissOptions

Source§

impl SerdeAPI for CabinOption

Source§

impl SerdeAPI for DriveTypes

Source§

impl SerdeAPI for HVACOption

Source§

impl SerdeAPI for CabinHeatSource

Source§

impl SerdeAPI for RESCoolingSource

Source§

impl SerdeAPI for RESHeatSource

Source§

impl SerdeAPI for TeRefComp

Source§

impl SerdeAPI for FuelConverterThermalOption

Source§

impl SerdeAPI for RESThermalOption

Source§

impl SerdeAPI for PowertrainType

Source§

impl SerdeAPI for AuxSource

Source§

impl SerdeAPI for Maneuver

Source§

const RESOURCES_SUBDIR: &'static str = "maneuvers"

Source§

impl SerdeAPI for ConstantJerkTrajectory

Source§

impl SerdeAPI for CycleCache

Source§

impl SerdeAPI for Cycle

Source§

const ACCEPTED_BYTE_FORMATS: &'static [&'static str]

Source§

const ACCEPTED_STR_FORMATS: &'static [&'static str]

Source§

const RESOURCES_SUBDIR: &'static str = "cycles"

Source§

impl SerdeAPI for CycleElement

Source§

impl SerdeAPI for Air

Source§

impl SerdeAPI for Octane

Source§

impl SerdeAPI for SimDrive

Source§

impl SerdeAPI for SimParams

Source§

impl SerdeAPI for TraceMissTolerance

Source§

impl SerdeAPI for AdjCoef

Source§

impl SerdeAPI for FuelProperties

Source§

impl SerdeAPI for LabelFe

Source§

impl SerdeAPI for LabelFePHEV

Source§

impl SerdeAPI for PHEVCycleCalc

Source§

impl SerdeAPI for PhevUtilizationParams

Source§

impl SerdeAPI for BatteryElectricVehicle

Source§

impl SerdeAPI for LumpedCabin

Source§

impl SerdeAPI for LumpedCabinState

Source§

impl SerdeAPI for LumpedCabinStateHistoryVec

Source§

impl SerdeAPI for Chassis

Source§

impl SerdeAPI for ConventionalVehicle

Source§

impl SerdeAPI for HybridElectricVehicle

Source§

impl SerdeAPI for RESGreedyWithDynamicBuffers

Source§

impl SerdeAPI for RGWDBState

Source§

impl SerdeAPI for RGWDBStateHistoryVec

Source§

impl SerdeAPI for HVACSystemForLumpedCabin

Source§

impl SerdeAPI for HVACSystemForLumpedCabinState

Source§

impl SerdeAPI for HVACSystemForLumpedCabinStateHistoryVec

Source§

impl SerdeAPI for HVACSystemForLumpedCabinAndRES

Source§

impl SerdeAPI for HVACSystemForLumpedCabinAndRESState

Source§

impl SerdeAPI for HVACSystemForLumpedCabinAndRESStateHistoryVec

Source§

impl SerdeAPI for ElectricMachine

Source§

impl SerdeAPI for ElectricMachineState

Source§

impl SerdeAPI for ElectricMachineStateHistoryVec

Source§

impl SerdeAPI for FuelConverter

Source§

impl SerdeAPI for FuelConverterState

Source§

impl SerdeAPI for FuelConverterStateHistoryVec

Source§

impl SerdeAPI for FuelConverterThermal

Source§

impl SerdeAPI for FuelConverterThermalState

Source§

impl SerdeAPI for FuelConverterThermalStateHistoryVec

Source§

impl SerdeAPI for FuelStorage

Source§

impl SerdeAPI for RESLumpedThermal

Source§

impl SerdeAPI for RESLumpedThermalState

Source§

impl SerdeAPI for RESLumpedThermalStateHistoryVec

Source§

impl SerdeAPI for ReversibleEnergyStorage

Source§

impl SerdeAPI for ReversibleEnergyStorageState

Source§

impl SerdeAPI for ReversibleEnergyStorageStateHistoryVec

Source§

impl SerdeAPI for Transmission

Source§

impl SerdeAPI for TransmissionState

Source§

impl SerdeAPI for TransmissionStateHistoryVec

Source§

impl SerdeAPI for Vehicle

Source§

const RESOURCES_SUBDIR: &'static str = "vehicles"

Source§

impl SerdeAPI for VehicleState

Source§

impl SerdeAPI for VehicleStateHistoryVec