Skip to main content

MemoryBackend

Struct MemoryBackend 

Source
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

Source

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.

Source

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.

Source

pub fn registered(&self, index: u32) -> Option<&[u8]>

Registered buffer index, if there is one.

Source

pub fn registered_mut(&mut self, index: u32) -> Option<&mut [u8]>

Registered buffer index, writable, if there is one.

Source

pub fn target(&self, key: IoTargetKey) -> Option<&MemoryTarget>

The target attached under key, if there is one.

Source

pub fn queued(&self) -> usize

How many submissions are queued, not yet submitted.

Source

pub fn completed(&self) -> usize

How many completions are ready, not yet popped.

Trait Implementations§

Source§

impl Debug for MemoryBackend

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl IoBackend for MemoryBackend

Source§

type Target = MemoryTarget

What it runs I/O for.
Source§

type Buffer = Vec<u8>

The owned buffers its submissions carry.
Source§

type Notification = MemoryNotification

What it raises when its completions go from none to some.
Source§

fn attach( &mut self, key: IoTargetKey, target: MemoryTarget, ) -> Result<(), DuplicateTarget<MemoryTarget>>

Run I/O for target under key. Read more
Source§

fn detach(&mut self, key: IoTargetKey) -> Option<MemoryTarget>

Stop running I/O for the target under 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

How many registered buffers it has; a RegisteredRegion names one by its position.
Source§

fn check( &self, target: IoTargetKey, op: &SubmissionOp<Vec<u8>>, ) -> Result<(), RefusalCause>

Whether 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
Source§

fn push( &mut self, submission: Submission<Vec<u8>>, ) -> Result<(), Refused<Vec<u8>>>

Queue submission, to be issued no later than the next submit. It is the backend’s from here until it completes: only a refusal hands it back. Read more
Source§

fn submit(&mut self) -> Result<(), RefusalCause>

Issue every queued submission. Read more
Source§

fn pop(&mut self) -> Result<Option<Completion<Vec<u8>>>, IoFault>

Take the oldest completion, if there is one. Read more
Source§

fn notification(&self) -> Result<MemoryNotification, IoFault>

A handle on its notification. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.