pub struct Timeframe {
pub value: u32,
pub unit: TimeframeUnit,
}Expand description
Represents a time interval for data aggregation
Fields§
§value: u32§unit: TimeframeUnitImplementations§
Source§impl Timeframe
impl Timeframe
Sourcepub fn new(value: u32, unit: TimeframeUnit) -> Timeframe
pub fn new(value: u32, unit: TimeframeUnit) -> Timeframe
Create a new timeframe
Sourcepub fn parse(s: &str) -> Option<Timeframe>
pub fn parse(s: &str) -> Option<Timeframe>
Parse a timeframe string like “5m”, “1h”, “4h”, “1d”, etc.
Sourcepub fn to_seconds(&self) -> u64
pub fn to_seconds(&self) -> u64
Convert to total seconds for comparison
Sourcepub fn can_aggregate_from(&self, base: &Timeframe) -> bool
pub fn can_aggregate_from(&self, base: &Timeframe) -> bool
Check if this timeframe can be aggregated from another
Sourcepub fn aggregation_factor(&self, base: &Timeframe) -> Option<usize>
pub fn aggregation_factor(&self, base: &Timeframe) -> Option<usize>
Calculate how many base rows are needed for this timeframe
Sourcepub fn align_timestamp(&self, timestamp: i64) -> i64
pub fn align_timestamp(&self, timestamp: i64) -> i64
Get alignment timestamp for a given timestamp For example, 9:32:45 with 5m timeframe aligns to 9:30:00
Sourcepub fn next_aligned_timestamp(&self, timestamp: i64) -> i64
pub fn next_aligned_timestamp(&self, timestamp: i64) -> i64
Get next aligned timestamp
pub fn m1() -> Timeframe
pub fn m5() -> Timeframe
pub fn m15() -> Timeframe
pub fn m30() -> Timeframe
pub fn h1() -> Timeframe
pub fn h4() -> Timeframe
pub fn d1() -> Timeframe
pub fn w1() -> Timeframe
Sourcepub fn is_intraday(&self) -> bool
pub fn is_intraday(&self) -> bool
Check if this is an intraday timeframe
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Timeframe
impl<'de> Deserialize<'de> for Timeframe
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Timeframe, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Timeframe, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Ord for Timeframe
impl Ord for Timeframe
Source§impl PartialOrd for Timeframe
impl PartialOrd for Timeframe
Source§impl Serialize for Timeframe
impl Serialize for Timeframe
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.