common_time::range

Type Alias TimestampRange

source
pub type TimestampRange = GenericRange<Timestamp>;

Aliased Type§

struct TimestampRange {
    start: Option<Timestamp>,
    end: Option<Timestamp>,
}

Fields§

§start: Option<Timestamp>§end: Option<Timestamp>

Implementations§

source§

impl TimestampRange

source

pub fn new_inclusive(start: Option<Timestamp>, end: Option<Timestamp>) -> Self

Create a TimestampRange with optional inclusive end timestamp. If end timestamp is present and is less than start timestamp, this method will return an empty range.

§Caveat

If the given end timestamp’s value is i64::MAX, which will result into overflow when added by 1(the end is inclusive), this method does not try to convert the time unit of end timestamp, instead it just return [start, INF). This exaggerates the range but does not affect correctness.

source

pub fn with_unit(start: i64, end: i64, unit: TimeUnit) -> Option<Self>

Shortcut method to create a timestamp range with given start/end value and time unit. Returns empty iff start > end.

source

pub fn single(ts: Timestamp) -> Self

Create a range that containing only given ts.

§Notice:

Left-close right-open range cannot properly represent range with a single value. For simplicity, this implementation returns an approximate range [ts, ts+1) instead.

source

pub fn from_start(start: Timestamp) -> Self

Create a range [start, INF).

§Notice

Left-close right-open range cannot properly represent range with exclusive start like: (start, ...). You may resort to [start-1, ...) instead.

source

pub fn until_end(end: Timestamp, inclusive: bool) -> Self

Create a range [-INF, end).

§Notice

Left-close right-open range cannot properly represent range with inclusive end like: [..., END]. If inclusive is true, this method returns [-INF, end+1) instead.

Trait Implementations§

source§

impl Display for TimestampRange

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more