Skip to main content

Stated

Struct Stated 

Source
pub struct Stated<P: Profile> { /* private fields */ }
Expand description

An instant together with the precision at which it was stated.

Rule T requires comparison across unequal precision to use interval semantics and to be able to return indeterminate. Carrying the precision alongside the value makes that the easy path: Stated::try_compare cannot be reached without confronting UCAL-E0023, whereas comparing two bare Instants that came from truncated text would quietly compare their floors.

This is what crate::codec::parse returns, as a pair; the type exists so the pair need not be carried by hand.

Implementations§

Source§

impl<P: Profile> Stated<P>

Source

pub fn new(value: Instant<P>, precision: Precision) -> Self

Pair a value with its stated precision.

Source

pub fn exact(value: Instant<P>) -> Self

A value stated to the tick.

Source

pub fn value(&self) -> &Instant<P>

The value as stated — its floor at the stated precision, not a tick unless the precision says so.

Source

pub fn precision(&self) -> Precision

The precision it was stated at.

Source

pub fn is_exact(&self) -> bool

Whether the statement pins a single tick.

Source

pub fn window(&self) -> Result<Window<P>>

The interval the statement denotes (Rule T).

Source

pub fn compare(&self, other: &Self) -> Result<IntervalOrdering>

Interval-aware comparison, which may be indeterminate.

Source

pub fn try_compare(&self, other: &Self) -> Result<Ordering>

Interval-aware comparison as a total order, or UCAL-E0023 when the intervals overlap and the order is genuinely not determined.

Source

pub fn coarsen(&self, to: Tier) -> Result<Stated<P>>

Re-state at a coarser precision. UCAL-E0023 if asked to refine, since no operation may invent precision the statement does not carry (F2).

Trait Implementations§

Source§

impl<P: Profile> Clone for Stated<P>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<P: Profile> Copy for Stated<P>

Available on crate feature u512 only.
Source§

impl<P: Profile> Debug for Stated<P>

Source§

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

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

impl<P: Profile> Eq for Stated<P>

Source§

impl<P: Profile> PartialEq for Stated<P>

Source§

fn eq(&self, other: &Self) -> bool

Equality is on the statement, not the interval: two statements are equal when they say the same thing at the same precision. Use Stated::try_compare to ask about the underlying instants.

1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl<P> Freeze for Stated<P>

§

impl<P> RefUnwindSafe for Stated<P>
where P: RefUnwindSafe,

§

impl<P> Send for Stated<P>
where P: Send,

§

impl<P> Sync for Stated<P>
where P: Sync,

§

impl<P> Unpin for Stated<P>
where P: Unpin,

§

impl<P> UnsafeUnpin for Stated<P>

§

impl<P> UnwindSafe for Stated<P>
where P: 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<U> As for U

Source§

fn as_<T>(self) -> T
where T: CastFrom<U>, U: Sized,

Casts self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. 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
Source§

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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, 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.