pub struct HostRing { /* private fields */ }Expand description
Default in-process ring backed by a Vec<u8>. Both RingProducer
and RingConsumer are implemented on a single &mut /& borrow
so the producer-consumer parity test can drive both halves with the
same buffer.
Implementations§
Source§impl HostRing
impl HostRing
Sourcepub fn new(slot_count: u32) -> Result<Self, ProtocolError>
pub fn new(slot_count: u32) -> Result<Self, ProtocolError>
Allocate a new ring of slot_count empty slots.
§Errors
Returns ProtocolError::ByteLengthOverflow if slot_count
exceeds protocol::MAX_ENCODED_RING_SLOTS.
Sourcepub fn as_bytes(&self) -> &[u8] ⓘ
pub fn as_bytes(&self) -> &[u8] ⓘ
Borrow the underlying ring bytes (for the dispatch path that
still consumes &[u8] directly).
Sourcepub fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ
pub fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ
Mutably borrow the underlying ring bytes.
Trait Implementations§
Source§impl RingConsumer for HostRing
impl RingConsumer for HostRing
Source§fn read_slot(&self, slot_idx: u32, out: &mut [u8]) -> Result<(), ProtocolError>
fn read_slot(&self, slot_idx: u32, out: &mut [u8]) -> Result<(), ProtocolError>
Copy slot
slot_idx’s bytes into out. out must be exactly
SLOT_BYTES long; otherwise returns
ProtocolError::MisalignedByteLength.Source§fn try_done_count(&self) -> Result<u32, ProtocolError>
fn try_done_count(&self) -> Result<u32, ProtocolError>
Fallibly count slots currently in
DONE status. Read moreSource§fn slot_count(&self) -> u32
fn slot_count(&self) -> u32
Number of slots in the underlying ring.
Source§fn done_count(&self) -> u32
fn done_count(&self) -> u32
👎Deprecated:
use RingConsumer::try_done_count so malformed ring snapshots do not collapse to zero
Compatibility-only lossy count of slots currently in
DONE status. Read moreSource§impl RingProducer for HostRing
impl RingProducer for HostRing
Source§fn publish(
&mut self,
slot_idx: u32,
encoded: &[u8],
) -> Result<(), ProtocolError>
fn publish( &mut self, slot_idx: u32, encoded: &[u8], ) -> Result<(), ProtocolError>
Publish
encoded into slot_idx. encoded must be exactly
SLOT_BYTES long; otherwise returns
ProtocolError::MisalignedByteLength.Source§fn slot_count(&self) -> u32
fn slot_count(&self) -> u32
Number of slots in the underlying ring.
Auto Trait Implementations§
impl Freeze for HostRing
impl RefUnwindSafe for HostRing
impl Send for HostRing
impl Sync for HostRing
impl Unpin for HostRing
impl UnsafeUnpin for HostRing
impl UnwindSafe for HostRing
Blanket Implementations§
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
Mutably borrows from an owned value. Read more