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
impl WindowGrant
Sourcepub fn try_new(
physical_ms: u64,
logical_start: u32,
count: u32,
epoch: Epoch,
) -> Result<Self, CoreError>
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.
pub fn physical_ms(&self) -> u64
pub fn logical_start(&self) -> u32
pub fn count(&self) -> u32
pub fn epoch(&self) -> Epoch
Trait Implementations§
Source§impl Clone for WindowGrant
impl Clone for WindowGrant
Source§fn clone(&self) -> WindowGrant
fn clone(&self) -> WindowGrant
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for WindowGrant
Source§impl Debug for WindowGrant
impl Debug for WindowGrant
impl Eq for WindowGrant
Source§impl PartialEq for WindowGrant
impl PartialEq for WindowGrant
Source§fn eq(&self, other: &WindowGrant) -> bool
fn eq(&self, other: &WindowGrant) -> bool
self and other values to be equal, and is used by ==.