pub struct ChainBuilder<M: MemOps> { /* private fields */ }Expand description
Builder for configuring a descriptor chain’s buffer layout.
If dropped without building, no resources are leaked (allocations are
deferred to build).
Implementations§
Source§impl<M: MemOps> ChainBuilder<M>
impl<M: MemOps> ChainBuilder<M>
Sourcepub fn readable(self, cap: usize) -> Self
pub fn readable(self, cap: usize) -> Self
Request a device-readable buffer of cap bytes.
The producer writes data into readable buffers before submission; the
consumer reads that data after polling the chain.
The actual allocation is deferred to build.
Sourcepub fn writable(self, cap: usize) -> Self
pub fn writable(self, cap: usize) -> Self
Request a device-writable buffer of cap bytes.
The writable buffer is filled by the consumer and returned via
VirtqProducer::poll as UsedChain.
Multiple writable buffers are completed as ordered Segments. The
consumer writes them sequentially, because the virtio used ring reports
one aggregate written length rather than per-descriptor lengths.
Sourcepub fn writable_avail(self) -> Self
pub fn writable_avail(self) -> Self
Request available upper-tier buffers within the ring budget.
build allocates these after all explicit requests.
This may add zero buffers. The complete chain must be nonempty.
Sourcepub fn build(self) -> Result<SendChain<M>, VirtqError>
pub fn build(self) -> Result<SendChain<M>, VirtqError>
Allocate buffers and return a SendChain for writing.
§Errors
VirtqError::InvalidState- no buffers requestedVirtqError::Backpressure- insufficient pool slots or ring descriptorsVirtqError::Bookkeeping- buffer record storage allocation failedVirtqError::Alloc- zero-length request or buffer allocation failed