pub enum Timeframe {
Seconds(u64),
Minutes(u64),
Hours(u64),
}Expand description
Supported bar timeframes.
Variants§
Seconds(u64)
Bar duration measured in seconds.
Minutes(u64)
Bar duration measured in minutes.
Hours(u64)
Bar duration measured in hours.
Implementations§
Source§impl Timeframe
impl Timeframe
Sourcepub fn duration_ms(self) -> u64
pub fn duration_ms(self) -> u64
Duration in milliseconds.
Sourcepub fn bar_start_ms(self, ts_ms: u64) -> u64
pub fn bar_start_ms(self, ts_ms: u64) -> u64
Bar start timestamp for a given ms timestamp.
Sourcepub fn from_duration_ms(ms: u64) -> Option<Timeframe>
pub fn from_duration_ms(ms: u64) -> Option<Timeframe>
Construct a Timeframe from a millisecond duration.
Prefers the largest canonical unit that divides evenly:
hours > minutes > seconds. Returns None if ms is zero or not a
whole number of seconds.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Timeframe
impl<'de> Deserialize<'de> for Timeframe
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 FromStr for Timeframe
impl FromStr for Timeframe
Source§fn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
Parse a timeframe string such as "1s", "5m", or "2h".
The format is a positive integer followed by a unit suffix:
s— seconds (e.g."30s")m— minutes (e.g."5m")h— hours (e.g."1h")
§Errors
Returns StreamError::ConfigError if the string is empty, has an
unknown suffix, or if the numeric part is zero or cannot be parsed.
Source§type Err = StreamError
type Err = StreamError
The associated error which can be returned from parsing.
Source§impl Ord for Timeframe
impl Ord for Timeframe
Source§fn cmp(&self, other: &Self) -> Ordering
fn cmp(&self, other: &Self) -> Ordering
Compares timeframes by their duration in milliseconds.
For example: Seconds(30) < Minutes(1) < Hours(1).
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for Timeframe
impl PartialOrd for Timeframe
impl Copy for Timeframe
impl Eq for Timeframe
impl StructuralPartialEq for Timeframe
Auto Trait Implementations§
impl Freeze for Timeframe
impl RefUnwindSafe for Timeframe
impl Send for Timeframe
impl Sync for Timeframe
impl Unpin for Timeframe
impl UnsafeUnpin for Timeframe
impl UnwindSafe for Timeframe
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