pub struct MemoryBackend { /* private fields */ }Expand description
The in-memory backend. Its buffers are Vec<u8>: a write’s length is its buffer’s, and a
read’s the most it transfers.
Implementations§
Source§impl MemoryBackend
impl MemoryBackend
Sourcepub fn new(
submission_queue_size: NonZero<u32>,
completion_queue_size: NonZero<u32>,
) -> MemoryBackend
pub fn new( submission_queue_size: NonZero<u32>, completion_queue_size: NonZero<u32>, ) -> MemoryBackend
A backend whose submission queue holds submission_queue_size submissions and whose
completion queue holds completion_queue_size completions, with no registered buffers.
Sourcepub fn with_registered(self, buffers: Vec<Vec<u8>>) -> MemoryBackend
pub fn with_registered(self, buffers: Vec<Vec<u8>>) -> MemoryBackend
Register buffers, in order, replacing any registered before: a backend’s buffers are
registered as it is built, before anything is pushed.
§Panics
If a submission is queued or a completion is waiting. A queued or finished operation may name a registered region, which replacing the buffers would invalidate; asking for it is a caller’s programming error.
Sourcepub fn registered(&self, index: u32) -> Option<&[u8]>
pub fn registered(&self, index: u32) -> Option<&[u8]>
Registered buffer index, if there is one.
Sourcepub fn registered_mut(&mut self, index: u32) -> Option<&mut [u8]>
pub fn registered_mut(&mut self, index: u32) -> Option<&mut [u8]>
Registered buffer index, writable, if there is one.
Sourcepub fn target(&self, key: IoTargetKey) -> Option<&MemoryTarget>
pub fn target(&self, key: IoTargetKey) -> Option<&MemoryTarget>
The target attached under key, if there is one.
Trait Implementations§
Source§impl Debug for MemoryBackend
impl Debug for MemoryBackend
Source§impl IoBackend for MemoryBackend
impl IoBackend for MemoryBackend
Source§type Target = MemoryTarget
type Target = MemoryTarget
Source§type Notification = MemoryNotification
type Notification = MemoryNotification
Source§fn attach(
&mut self,
key: IoTargetKey,
target: MemoryTarget,
) -> Result<(), DuplicateTarget<MemoryTarget>>
fn attach( &mut self, key: IoTargetKey, target: MemoryTarget, ) -> Result<(), DuplicateTarget<MemoryTarget>>
Source§fn detach(&mut self, key: IoTargetKey) -> Option<MemoryTarget>
fn detach(&mut self, key: IoTargetKey) -> Option<MemoryTarget>
key, handing it back; None if there is none. A
submission for it queued but not yet submitted still completes exactly once, through
pop: with a fault, or, for a backend that cannot take a queued submission
back, issued as it would have been, to the file it was pushed for. The core detaches a
target only with no operation outstanding, so a driver does not meet either.Source§fn registered_buffers(&self) -> u32
fn registered_buffers(&self) -> u32
RegisteredRegion names one by its position.Source§fn check(
&self,
target: IoTargetKey,
op: &SubmissionOp<Vec<u8>>,
) -> Result<(), RefusalCause>
fn check( &self, target: IoTargetKey, op: &SubmissionOp<Vec<u8>>, ) -> Result<(), RefusalCause>
push would refuse op on target for a cause that does not depend
on its queues: no target under the key, an operation it cannot perform, or one malformed for
its target. The core asks before it holds an operation for its gate, so a gated operation is
refused at the consumer’s push for what an ungated one would be (DI-D-54). A push this
accepts may still be refused for a full queue, or by a backend that has become unusable. Read more