#[non_exhaustive]pub struct Cycle {
pub name: String,
pub init_elev: Option<Length>,
pub time: Vec<Time>,
pub speed: Vec<Velocity>,
pub dist: Vec<Length>,
pub grade: Vec<Ratio>,
pub elev: Vec<Length>,
pub pwr_max_chrg: Vec<Power>,
pub temp_amb_air: Vec<Temperature>,
pub pwr_solar_load: Vec<Power>,
pub grade_interp: Option<Interpolator>,
pub elev_interp: Option<Interpolator>,
}Expand description
Container
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.name: StringName of cycle (can be left empty)
init_elev: Option<Length>inital elevation
time: Vec<Time>simulation time
speed: Vec<Velocity>prescribed speed
dist: Vec<Length>calculated prescribed distance based on RHS integral of time and speed
grade: Vec<Ratio>road grade (expressed as a decimal, not percent)
elev: Vec<Length>calculated prescribed elevation based on RHS integral distance and grade
pwr_max_chrg: Vec<Power>road charging/discharing capacity
temp_amb_air: Vec<Temperature>ambient air temperature w.r.t. to time (rather than spatial position)
pwr_solar_load: Vec<Power>solar heat load w.r.t. to time (rather than spatial position)
grade_interp: Option<Interpolator>grade interpolator
elev_interp: Option<Interpolator>elevation interpolator
Implementations§
Source§impl Cycle
impl Cycle
pub fn len_checked(&self) -> Result<usize>
pub fn is_empty(&self) -> Result<bool>
pub fn push(&mut self, element: CycleElement) -> Result<()>
pub fn extend(&mut self, vec: Vec<CycleElement>) -> Result<()>
pub fn trim( &mut self, start_idx: Option<usize>, end_idx: Option<usize>, ) -> Result<()>
pub fn to_fastsim2(&self) -> Result<Cycle2>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Cycle
impl<'de> Deserialize<'de> for Cycle
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl SerdeAPI for Cycle
impl SerdeAPI for Cycle
Source§fn to_writer<W: Write>(&self, wtr: W, format: &str) -> Result<(), Error>
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 dataformat- The target format, any of those listed inACCEPTED_BYTE_FORMATS
Source§fn from_reader<R: Read>(
rdr: &mut R,
format: &str,
skip_init: bool,
) -> Result<Self, Error>
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 dataformat- The source format, any of those listed inACCEPTED_BYTE_FORMATS
Source§fn to_str(&self, format: &str) -> Result<String>
fn to_str(&self, format: &str) -> Result<String>
Write (serialize) an object into a string
§Arguments:
format- The target format, any of those listed inACCEPTED_STR_FORMATS
Source§fn from_str<S: AsRef<str>>(
contents: S,
format: &str,
skip_init: bool,
) -> Result<Self>
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 dataformat- The source format, any of those listed inACCEPTED_STR_FORMATS
const ACCEPTED_BYTE_FORMATS: &'static [&'static str]
const ACCEPTED_STR_FORMATS: &'static [&'static str]
const RESOURCE_PREFIX: &'static str = "cycles"
Source§fn from_resource<P: AsRef<Path>>(
filepath: P,
skip_init: bool,
) -> Result<Self, Error>
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 Read moreSource§fn to_file<P: AsRef<Path>>(&self, filepath: P) -> Result<(), Error>
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. Read moreSource§fn from_file<P: AsRef<Path>>(
filepath: P,
skip_init: bool,
) -> Result<Self, Error>
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. Read moreSource§fn from_json<S: AsRef<str>>(json_str: S, skip_init: bool) -> Result<Self>
fn from_json<S: AsRef<str>>(json_str: S, skip_init: bool) -> Result<Self>
Read (deserialize) an object from a JSON string Read more
Source§fn from_msg_pack(msg_pack: &[u8], skip_init: bool) -> Result<Self>
fn from_msg_pack(msg_pack: &[u8], skip_init: bool) -> Result<Self>
Read (deserialize) an object from a message pack Read more
impl StructuralPartialEq for Cycle
Auto Trait Implementations§
impl Freeze for Cycle
impl RefUnwindSafe for Cycle
impl Send for Cycle
impl Sync for Cycle
impl Unpin for Cycle
impl UnwindSafe for Cycle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more