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) -> Self
pub fn new(value: u32, unit: TimeframeUnit) -> Self
Create a new timeframe
Sourcepub fn parse(s: &str) -> Option<Self>
pub fn parse(s: &str) -> Option<Self>
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() -> Self
pub fn m5() -> Self
pub fn m15() -> Self
pub fn m30() -> Self
pub fn h1() -> Self
pub fn h4() -> Self
pub fn d1() -> Self
pub fn w1() -> Self
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<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 Ord for Timeframe
impl Ord for Timeframe
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