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_SUBDIR: &'static str = "";
    const RESOURCES_DIR: &'static Dir<'_> = _;
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<()> { ... } 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<()> { ... } fn to_str(&self, format: &str) -> Result<String> { ... } fn from_str<S: AsRef<str>>( contents: S, format: &str, skip_init: bool, ) -> Result<Self> { ... } fn from_reader<R: Read>( rdr: &mut R, format: &str, skip_init: bool, ) -> Result<Self, Error> { ... } 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_SUBDIR: &'static str = ""

Source

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

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 altrios-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<()>

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<()>

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 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 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_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<T: SerdeAPI> SerdeAPI for Vec<T>

Implementors§

Source§

impl SerdeAPI for PowerDistributionControlType

Source§

impl SerdeAPI for HybridPowertrainControls

Source§

impl SerdeAPI for PowertrainType

Source§

impl SerdeAPI for TrainRes

Source§

impl SerdeAPI for Consist

Source§

impl SerdeAPI for ConsistState

Source§

impl SerdeAPI for ConsistStateHistoryVec

Source§

impl SerdeAPI for ConsistSimulation

Source§

impl SerdeAPI for FrontAndBack

Source§

impl SerdeAPI for Pyo3VecLocoWrapper

Source§

impl SerdeAPI for BatteryElectricLoco

Source§

impl SerdeAPI for RESGreedyWithDynamicBuffersBEL

Source§

impl SerdeAPI for RGWDBStateBEL

Source§

impl SerdeAPI for RGWDBStateBELHistoryVec

Source§

impl SerdeAPI for ConventionalLoco

Source§

impl SerdeAPI for HybridLoco

Source§

impl SerdeAPI for RESGreedyWithDynamicBuffers

Source§

impl SerdeAPI for RGWDBState

Source§

impl SerdeAPI for RGWDBStateHistoryVec

Source§

impl SerdeAPI for LocomotiveSimulation

Source§

impl SerdeAPI for LocomotiveSimulationVec

Source§

impl SerdeAPI for PowerTrace

Source§

impl SerdeAPI for DummyLoco

Source§

impl SerdeAPI for LocoParams

Source§

impl SerdeAPI for Locomotive

Source§

impl SerdeAPI for LocomotiveState

Source§

impl SerdeAPI for LocomotiveStateHistoryVec

Source§

impl SerdeAPI for ElectricDrivetrain

Source§

impl SerdeAPI for ElectricDrivetrainState

Source§

impl SerdeAPI for ElectricDrivetrainStateHistoryVec

Source§

impl SerdeAPI for FuelConverter

Source§

impl SerdeAPI for FuelConverterState

Source§

impl SerdeAPI for FuelConverterStateHistoryVec

Source§

impl SerdeAPI for Generator

Source§

impl SerdeAPI for GeneratorState

Source§

impl SerdeAPI for GeneratorStateHistoryVec

Source§

impl SerdeAPI for ReversibleEnergyStorage

Source§

impl SerdeAPI for ReversibleEnergyStorageState

Source§

impl SerdeAPI for ReversibleEnergyStorageStateHistoryVec

Source§

impl SerdeAPI for EstTimeNet

Source§

impl SerdeAPI for SavedSim

Source§

impl SerdeAPI for CatPowerLimit

Source§

impl SerdeAPI for Elev

Source§

impl SerdeAPI for Heading

Source§

impl SerdeAPI for LinkIdx

Source§

impl SerdeAPI for LinkPath

Source§

impl SerdeAPI for LinkPoint

Source§

impl SerdeAPI for Location

Source§

impl SerdeAPI for Network

Source§

impl SerdeAPI for NetworkErrTol

Source§

impl SerdeAPI for OldSpeedSet

Source§

impl SerdeAPI for PathResCoeff

Source§

impl SerdeAPI for PathTpc

Source§

impl SerdeAPI for SpeedLimit

Source§

impl SerdeAPI for SpeedSet

Source§

impl SerdeAPI for altrios_core::train::kind::aerodynamic::Basic

Source§

impl SerdeAPI for altrios_core::train::kind::davis_b::Basic

Source§

impl SerdeAPI for altrios_core::train::kind::path_res::Point

Source§

impl SerdeAPI for altrios_core::train::kind::path_res::Strap

Source§

impl SerdeAPI for altrios_core::train::kind::rolling::Basic

Source§

impl SerdeAPI for altrios_core::train::method::Point

Source§

impl SerdeAPI for altrios_core::train::method::Strap

Source§

impl SerdeAPI for InitTrainState

Source§

impl SerdeAPI for InitTrainStateHistoryVec

Source§

impl SerdeAPI for LinkIdxTime

Source§

impl SerdeAPI for RailVehicle

Source§

impl SerdeAPI for SetSpeedTrainSim

Source§

impl SerdeAPI for SpeedLimitTrainSim

Source§

impl SerdeAPI for SpeedLimitTrainSimVec

Source§

impl SerdeAPI for SpeedTrace

Source§

impl SerdeAPI for TemperatureTrace

Source§

impl SerdeAPI for TemperatureTraceBuilder

Source§

impl SerdeAPI for TimedLinkPath

Source§

impl SerdeAPI for TrainConfig

Source§

impl SerdeAPI for TrainResWrapper

Source§

impl SerdeAPI for TrainSimBuilder

Source§

impl SerdeAPI for TrainState

Source§

impl SerdeAPI for TrainStateHistoryVec

Source§

impl<T> SerdeAPI for ValRange<T>
where T: Serialize + for<'a> Deserialize<'a>,