pub struct TimeRange {
pub start: Timestamp,
pub end: Timestamp,
}Expand description
Time range for temporal queries.
Represents a span of time with start and end timestamps.
§Examples
use spatial_narrative::core::{TimeRange, Timestamp};
// Create a range for March 2024
let march = TimeRange::month(2024, 3);
// Check if a timestamp is within range
let ts = Timestamp::parse("2024-03-15T12:00:00Z").unwrap();
assert!(march.contains(&ts));Fields§
§start: TimestampStart of the range (inclusive).
end: TimestampEnd of the range (inclusive).
Implementations§
Source§impl TimeRange
impl TimeRange
Sourcepub fn last(duration: Duration) -> Self
pub fn last(duration: Duration) -> Self
Creates a time range from now going back by the given duration.
Sourcepub fn next(duration: Duration) -> Self
pub fn next(duration: Duration) -> Self
Creates a time range from now going forward by the given duration.
Sourcepub fn contains(&self, timestamp: &Timestamp) -> bool
pub fn contains(&self, timestamp: &Timestamp) -> bool
Checks if a timestamp is within this range.
Sourcepub fn intersection(&self, other: &TimeRange) -> Option<TimeRange>
pub fn intersection(&self, other: &TimeRange) -> Option<TimeRange>
Returns the intersection of two ranges, if any.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TimeRange
impl<'de> Deserialize<'de> for TimeRange
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
impl Eq for TimeRange
impl StructuralPartialEq for TimeRange
Auto Trait Implementations§
impl Freeze for TimeRange
impl RefUnwindSafe for TimeRange
impl Send for TimeRange
impl Sync for TimeRange
impl Unpin for TimeRange
impl UnwindSafe for TimeRange
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> 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.