pub struct RecvChain<M: MemOps> { /* private fields */ }Expand description
Stateful reader over device-readable descriptors received from the producer.
Reads copy directly from shared memory into caller-provided final storage.
The chain must be returned together with its paired ReplyChain through
VirtqConsumer::complete before the descriptors can be reused.
Implementations§
Source§impl<M: MemOps> RecvChain<M>
impl<M: MemOps> RecvChain<M>
Sourcepub fn read(&mut self, buf: &mut [u8]) -> Result<usize, VirtqError>
pub fn read(&mut self, buf: &mut [u8]) -> Result<usize, VirtqError>
Read bytes sequentially across descriptor boundaries.
Returns the number of bytes copied, which may be smaller than buf.len()
at the end of the chain. If a later memory read fails, the cursor remains
advanced past any earlier chunks copied by the same call.
Sourcepub fn read_exact(&mut self, buf: &mut [u8]) -> Result<&mut Self, VirtqError>
pub fn read_exact(&mut self, buf: &mut [u8]) -> Result<&mut Self, VirtqError>
Read exactly buf.len() bytes or return an error.
Sourcepub fn to_segments(&self) -> Result<Segments, VirtqError>
pub fn to_segments(&self) -> Result<Segments, VirtqError>
Copy the complete payload into descriptor-preserving owned segments.
This does not change the stateful read position. Each call takes a new snapshot of shared memory; callers should validate and use the returned owned value rather than reading the same untrusted payload again.
§Errors
Returns VirtqError::Bookkeeping for allocation failures or
VirtqError::MemoryReadError for unreadable payloads.
Sourcepub fn to_bytes(&self) -> Result<Bytes, VirtqError>
pub fn to_bytes(&self) -> Result<Bytes, VirtqError>
Copy the complete payload directly into one contiguous allocation.
This does not change the stateful read position. Each call takes a new snapshot of shared memory; callers should validate and use the returned owned value rather than reading the same untrusted payload again.
§Errors
Returns VirtqError::Bookkeeping for allocation failures or
VirtqError::MemoryReadError for unreadable payloads.
Trait Implementations§
Source§impl<M: MemOps> ExternalValueSource for RecvChain<M>
Copies values so later shared-memory writes cannot change decoded arguments.
impl<M: MemOps> ExternalValueSource for RecvChain<M>
Copies values so later shared-memory writes cannot change decoded arguments.