common_time::range

Struct GenericRange

source
pub struct GenericRange<T> {
    start: Option<T>,
    end: Option<T>,
}
Expand description

A half-open time range.

The range contains values that value >= start and val < end.

The range is empty iff start == end == "the default value of T"

Fields§

§start: Option<T>§end: Option<T>

Implementations§

source§

impl<T> GenericRange<T>
where T: Copy + PartialOrd + Default,

source

pub fn and(&self, other: &GenericRange<T>) -> GenericRange<T>

Computes the AND’ed range with other.

source

pub fn or(&self, other: &GenericRange<T>) -> GenericRange<T>

Compute the OR’ed range of two ranges. Notice: this method does not compute the exact OR’ed operation for simplicity. For example, [1, 2) or’ed with [4, 5) will produce [1, 5) instead of [1, 2) ∪ [4, 5)

source

pub fn intersects(&self, target: &GenericRange<T>) -> bool

Checks if current range intersect with target.

source

pub fn empty() -> GenericRange<T>

Create an empty range.

source

fn from_optional(start: Option<T>, end: Option<T>) -> GenericRange<T>

Create GenericRange from optional start and end. If the present value of start >= the present value of end, it will return an empty range with the default value of T.

source§

impl<T> GenericRange<T>

source

pub fn new<U: PartialOrd + Into<T>>(start: U, end: U) -> Option<GenericRange<T>>

Creates a new range that contains values in [start, end).

Returns None if start > end.

source

pub fn min_to_max() -> GenericRange<T>

Return a range containing all possible values.

source

pub fn start(&self) -> &Option<T>

Returns the lower bound of the range (inclusive).

source

pub fn end(&self) -> &Option<T>

Returns the upper bound of the range (exclusive).

source

pub fn contains<U: PartialOrd<T>>(&self, target: &U) -> bool

Returns true if timestamp is contained in the range.

source§

impl<T: PartialOrd> GenericRange<T>

source

pub fn is_empty(&self) -> bool

Returns true if the range contains no timestamps.

source§

impl GenericRange<Timestamp>

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<T: Clone> Clone for GenericRange<T>

source§

fn clone(&self) -> GenericRange<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Debug> Debug for GenericRange<T>

source§

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

Formats the value using the given formatter. Read more
source§

impl<'de, T> Deserialize<'de> for GenericRange<T>
where T: Deserialize<'de>,

source§

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<T: Hash> Hash for GenericRange<T>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<T: PartialEq> PartialEq for GenericRange<T>

source§

fn eq(&self, other: &GenericRange<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T> Serialize for GenericRange<T>
where T: Serialize,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<T: Copy> Copy for GenericRange<T>

source§

impl<T: Eq> Eq for GenericRange<T>

source§

impl<T> StructuralPartialEq for GenericRange<T>

Auto Trait Implementations§

§

impl<T> Freeze for GenericRange<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for GenericRange<T>
where T: RefUnwindSafe,

§

impl<T> Send for GenericRange<T>
where T: Send,

§

impl<T> Sync for GenericRange<T>
where T: Sync,

§

impl<T> Unpin for GenericRange<T>
where T: Unpin,

§

impl<T> UnwindSafe for GenericRange<T>
where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CallHasher for T
where T: Hash + ?Sized,

§

default fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64
where H: Hash + ?Sized, B: BuildHasher,

source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,