pub struct OutgoingRing<M: RingMem> { /* private fields */ }
Expand description
The sending side of a ring buffer.
Implementations§
Source§impl<M: RingMem> OutgoingRing<M>
impl<M: RingMem> OutgoingRing<M>
Sourcepub fn outgoing(&self) -> Result<OutgoingOffset, Error>
pub fn outgoing(&self) -> Result<OutgoingOffset, Error>
Returns the current outgoing offset, for passing to write
and
ultimately commit_write
.
Sourcepub fn set_pending_send_size(&self, len: usize) -> Result<(), Error>
pub fn set_pending_send_size(&self, len: usize) -> Result<(), Error>
Sets the pending send size: the number of bytes that should be free in the ring before the opposite endpoint sends a ring-non-full signal.
Fails if the packet size is larger than the ring’s maximum packet size.
Sourcepub fn maximum_packet_size(&self) -> usize
pub fn maximum_packet_size(&self) -> usize
Returns the maximum packet size that can fit in the ring.
Sourcepub fn can_write(
&self,
ptrs: &mut OutgoingOffset,
len: usize,
) -> Result<bool, Error>
pub fn can_write( &self, ptrs: &mut OutgoingOffset, len: usize, ) -> Result<bool, Error>
Returns whether a packet can fit in the ring starting at the specified offset.
Sourcepub fn commit_write(&self, ptrs: &mut OutgoingOffset) -> bool
pub fn commit_write(&self, ptrs: &mut OutgoingOffset) -> bool
Commits a series of writes that ended at the specified offset, returning whether the opposite endpoint should be signaled.
Sourcepub fn write(
&self,
ptrs: &mut OutgoingOffset,
packet: &OutgoingPacket<'_>,
) -> Result<RingRange, WriteError>
pub fn write( &self, ptrs: &mut OutgoingOffset, packet: &OutgoingPacket<'_>, ) -> Result<RingRange, WriteError>
Writes the header of the next packet and returns the ring range for the
payload. The caller should write the payload, then commit the write (or
multiple writes) with commit_write
.
Returns Err(RingFull(len))
if the ring is full, where len
is the
number of bytes needed to write the requested packet.