Skip to main content

WindowGrant

Struct WindowGrant 

Source
pub struct WindowGrant { /* private fields */ }
Expand description

A contiguous block of count timestamps starting at (physical_ms, logical_start), all sharing one leadership epoch.

Fields are private and the only public constructor is try_new, which validates that every timestamp the grant covers fits the packed 46-bit physical / 18-bit logical layout. A value of this type is therefore proof that first and last can pack without panicking — the in-range invariant is guaranteed by the type, not by the constructors that happen to build it. The crate-internal back door new_unchecked skips the validation but documents the same invariant as a caller obligation.

Implementations§

Source§

impl WindowGrant

Source

pub fn try_new( physical_ms: u64, logical_start: u32, count: u32, epoch: Epoch, ) -> Result<Self, CoreError>

Construct a grant, checking that every timestamp it covers packs cleanly. This is the only validating constructor; the crate-internal new_unchecked skips the checks but requires the caller to have established the invariant some other way. Either way, a constructed value witnesses that first/last are infallible.

Rejects count == 0 (a grant covers at least one timestamp, and last’s logical_start + count - 1 would underflow). The range check defers to Timestamp::try_pack on the last logical the grant emits: it is the single source of truth for the bit layout, and since logical_start <= last_logical <= LOGICAL_MAX validating the last boundary validates the first by implication.

Source

pub fn physical_ms(&self) -> u64

Source

pub fn logical_start(&self) -> u32

Source

pub fn count(&self) -> u32

Source

pub fn epoch(&self) -> Epoch

Source

pub fn first(&self) -> Timestamp

The first timestamp in the grant. Infallible: try_new validated (physical_ms, logical_start) is in range, so pack cannot trip its assert!.

Source

pub fn last(&self) -> Timestamp

The last timestamp in the grant. Infallible: try_new validated (physical_ms, logical_start + count - 1) is in range (and count >= 1, so the subtraction cannot underflow), so pack cannot trip its assert!.

Trait Implementations§

Source§

impl Clone for WindowGrant

Source§

fn clone(&self) -> WindowGrant

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 Copy for WindowGrant

Source§

impl Debug for WindowGrant

Source§

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

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

impl Eq for WindowGrant

Source§

impl PartialEq for WindowGrant

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 StructuralPartialEq for WindowGrant

Auto Trait Implementations§

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