pub struct MemHedgeRead<'a, 's, T, const N: usize> { /* private fields */ }Expand description
๐ซ ๐งต ๐ โฌก Binds a hedge-control cell to a replicated logical slice view.
๐ sys/mem/cell
MemHedgeRead does not spawn workers or perform any platform-specific work.
It only provides the protocol-facing surface that connects:
MemReplicaSliceas the replicated data source,MemHedgeCtrlas the shared coordination state.
This is the first layer where the hedged-read pattern becomes explicit.
Implementationsยง
Sourceยงimpl<'a, 's, T, const N: usize> MemHedgeRead<'a, 's, T, N>
impl<'a, 's, T, const N: usize> MemHedgeRead<'a, 's, T, N>
Sourcepub const fn new(
ctrl: &'a MemHedgeCtrl,
replicas: &'a MemReplicaSlice<'s, T, N>,
) -> Self
pub const fn new( ctrl: &'a MemHedgeCtrl, replicas: &'a MemReplicaSlice<'s, T, N>, ) -> Self
Creates a hedge-read faรงade over ctrl and replicas.
Sourcepub const fn ctrl(&self) -> &'a MemHedgeCtrl
pub const fn ctrl(&self) -> &'a MemHedgeCtrl
Returns the underlying hedge-control cell.
Sourcepub const fn replicas(&self) -> &'a MemReplicaSlice<'s, T, N>
pub const fn replicas(&self) -> &'a MemReplicaSlice<'s, T, N>
Returns the underlying replicated slice view.
Sourcepub fn arm(&self, logical_index: usize) -> Result<usize, MemHedgeError> โ
pub fn arm(&self, logical_index: usize) -> Result<usize, MemHedgeError> โ
Arms a hedged read request for logical_index.
This validates that the requested index lies within the initialized
logical length of the replicated view before delegating to
MemHedgeCtrl::arm.
ยงErrors
Returns:
MemHedgeError::OutOfBoundsiflogical_index >= replicas.len().- any error returned by
MemHedgeCtrl::arm.
Sourcepub fn clear(&self)
pub fn clear(&self)
Clears the current request state.
This delegates to MemHedgeCtrl::clear.
Sourcepub fn logical_index(&self) -> usize
pub fn logical_index(&self) -> usize
Returns the currently requested logical index.
Sourcepub fn state(&self) -> MemHedgeState
pub fn state(&self) -> MemHedgeState
Returns the current hedge lifecycle state.
Sourcepub fn read(&self) -> Result<&T, MemHedgeError> โ
pub fn read(&self) -> Result<&T, MemHedgeError> โ
Reads the first replica for the currently active request.
This is a convenience alias for read_replica
with replica = 0.
ยงErrors
Returns:
MemHedgeError::NotArmedif no request is active,MemHedgeError::OutOfBoundsif the active logical index is not readable in the bound replica view.
Sourcepub fn read_replica(&self, replica: usize) -> Result<&T, MemHedgeError> โ
pub fn read_replica(&self, replica: usize) -> Result<&T, MemHedgeError> โ
Reads one replica for the currently active request.
This uses the logical index published in the bound MemHedgeCtrl.
ยงErrors
Returns:
MemHedgeError::NotArmedif no request is active,MemHedgeError::InvalidReplicaifreplica >= N,MemHedgeError::OutOfBoundsif the active logical index is not readable in the bound replica view.
Sourcepub fn try_read_claim(
&self,
replica: usize,
) -> Result<Option<&T>, MemHedgeError> โ
pub fn try_read_claim( &self, replica: usize, ) -> Result<Option<&T>, MemHedgeError> โ
Reads one replica and then attempts to claim the active request.
This is the worker-facing convenience operation:
- read the replica corresponding to
replica, - try to claim victory for that replica,
- return the read value only if this replica won.
Returns:
Ok(Some(&T))if this replica became the winner,Ok(None)if another replica won first while the request was still armed,Err(...)if the request was not active or the indices were invalid.
Trait Implementationsยง
Sourceยงimpl<'a, 's, T: Clone, const N: usize> Clone for MemHedgeRead<'a, 's, T, N>
impl<'a, 's, T: Clone, const N: usize> Clone for MemHedgeRead<'a, 's, T, N>
Sourceยงfn clone(&self) -> MemHedgeRead<'a, 's, T, N>
fn clone(&self) -> MemHedgeRead<'a, 's, T, N>
1.0.0 (const: unstable) ยท Sourceยงfn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl<'a, 's, T: Copy, const N: usize> Copy for MemHedgeRead<'a, 's, T, N>
Auto Trait Implementationsยง
impl<'a, 's, T, const N: usize> Freeze for MemHedgeRead<'a, 's, T, N>
impl<'a, 's, T, const N: usize> RefUnwindSafe for MemHedgeRead<'a, 's, T, N>where
T: RefUnwindSafe,
impl<'a, 's, T, const N: usize> Send for MemHedgeRead<'a, 's, T, N>where
T: Sync,
impl<'a, 's, T, const N: usize> Sync for MemHedgeRead<'a, 's, T, N>where
T: Sync,
impl<'a, 's, T, const N: usize> Unpin for MemHedgeRead<'a, 's, T, N>
impl<'a, 's, T, const N: usize> UnsafeUnpin for MemHedgeRead<'a, 's, T, N>
impl<'a, 's, T, const N: usize> UnwindSafe for MemHedgeRead<'a, 's, T, N>where
T: RefUnwindSafe,
Blanket Implementationsยง
Sourceยงimpl<T> AnyExt for T
impl<T> AnyExt for T
Sourceยงfn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
TypeId of Self using a custom hasher.Sourceยงfn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
Sourceยงfn as_any_box(self: Box<Self>) -> Box<dyn Any>where
Self: Sized,
fn as_any_box(self: Box<Self>) -> Box<dyn Any>where
Self: Sized,
alloc only.Sourceยงimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Sourceยงfn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Sourceยงimpl<T> ByteSized for T
impl<T> ByteSized for T
Sourceยงconst BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
Sourceยงfn byte_align(&self) -> usize
fn byte_align(&self) -> usize
Sourceยงfn ptr_size_ratio(&self) -> [usize; 2]
fn ptr_size_ratio(&self) -> [usize; 2]
Sourceยงimpl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Sourceยงimpl<T> MemExt for Twhere
T: ?Sized,
impl<T> MemExt for Twhere
T: ?Sized,
Sourceยงconst NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
Sourceยงfn mem_align_of<T>() -> usize
fn mem_align_of<T>() -> usize
Sourceยงfn mem_align_of_val(&self) -> usize
fn mem_align_of_val(&self) -> usize
Sourceยงfn mem_size_of<T>() -> usize
fn mem_size_of<T>() -> usize
Sourceยงfn mem_size_of_val(&self) -> usize
fn mem_size_of_val(&self) -> usize
Sourceยงfn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
true if dropping values of this type matters. Read moreSourceยงfn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
self without running its destructor. Read moreSourceยงfn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
Sourceยงunsafe fn mem_zeroed<T>() -> T
unsafe fn mem_zeroed<T>() -> T
unsafe_layout only.T represented by the all-zero byte-pattern. Read moreSourceยงunsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe_layout only.T represented by the all-zero byte-pattern. Read moreSourceยงfn mem_as_bytes(&self) -> &[u8] โ
fn mem_as_bytes(&self) -> &[u8] โ
unsafe_slice only.