Struct IoVector

Source
pub struct IoVector<'a> {
    vector: Vec<IoSlice<'a>>,
    total_size: u64,
}
Expand description

Vector of memory buffers.

Fields§

§vector: Vec<IoSlice<'a>>

Buffer list.

§total_size: u64

Complete size in bytes.

Implementations§

Source§

impl<'a> IoVector<'a>

Source

pub fn new() -> Self

Create an empty vector.

Source

pub fn with_capacity(cap: usize) -> Self

Create an empty vector, pre-allocating space for cap buffers.

This does not allocate an memory buffer, only space in the buffer vector.

Source

pub fn push(&mut self, slice: &'a [u8])

Append a slice.

Source

pub fn push_ioslice(&mut self, ioslice: IoSlice<'a>)

Append a slice.

Source

pub fn insert(&mut self, index: usize, slice: &'a [u8])

Insert a slice at the given index in the buffer vector.

Source

pub fn len(&self) -> u64

Return the sum total length in bytes of all buffers in this vector.

Source

pub fn buffer_count(&self) -> usize

Return the number of buffers in this vector.

Source

pub fn is_empty(&self) -> bool

Return true if and only if this vector’s length is zero.

Synonymous with whether this vector’s buffer count is zero.

Source

pub fn append(&mut self, other: Self)

Append all buffers from the given other vector to this vector.

Source

pub fn split_at(self, mid: u64) -> (Self, Self)

Split the vector into two.

The first returned vector contains the bytes in the [..mid] range, and the second one covers the [mid..] range.

Source

pub fn split_tail_at(self, mid: u64) -> Self

Like Self::split_at(), but discards the head, only returning the tail.

More efficient than to use self.split_at(mid).1 because the former requires creating a new Vec object for the head, which this version skips.

Source

pub fn copy_into_slice(&self, slice: &mut [u8])

Copy the data from self into slice.

Both must have the same length.

Source

pub fn try_into_owned(self, alignment: usize) -> Result<IoBuffer>

Create a single owned IoBuffer with the same data (copied).

Source

pub unsafe fn as_iovec<'b>(&'b self) -> &'b [iovec]
where Self: 'b,

Return a corresponding &[libc::iovec].

§Safety

iovec has no lifetime information. Callers must ensure no elements in the returned slice are used beyond the lifetime '_.

Source

pub fn is_aligned(&self, mem_alignment: usize, req_alignment: usize) -> bool

Check whether self is aligned.

Each buffer must be aligned to mem_alignment, and each buffer’s length must be aligned to both mem_alignment and req_alignment (the I/O request offset/size alignment).

Source

pub fn into_inner(self) -> Vec<IoSlice<'a>>

Return the internal vector of IoSlice objects.

Source

pub fn with_pushed<'b>(self, slice: &'b [u8]) -> IoVector<'b>
where 'a: 'b,

Same as Self::push(), but takes ownership of self.

By taking ownership of self and returning it, this method allows reducing the lifetime of self to that of slice, if necessary.

Source

pub fn with_inserted<'b>(self, index: usize, slice: &'b [u8]) -> IoVector<'b>
where 'a: 'b,

Same as Self::insert(), but takes ownership of self.

By taking ownership of self and returning it, this method allows reducing the lifetime of self to that of slice, if necessary.

Source

fn do_split_at( self, mid: u64, keep_head: bool, ) -> (Option<IoVector<'a>>, IoVector<'a>)

Implementation for Self::split_at() and Self::split_tail_at().

If keep_head is true, both head and tail are returned (Self::split_at()). Otherwise, the head is discarded (Self::split_tail_at()).

Source§

impl<'a> IoVector<'a>

Source

pub fn from_volatile_slice<B: BitmapSlice, I: IntoIterator<Item: ImagoAsRef<'a, VolatileSlice<'a, B>>, IntoIter: ExactSizeIterator>>( slices: I, ) -> (Self, VolatileSliceGuard<'a, PtrGuard, B>)

Converts a VolatileSlice array (from vm-memory) into an IoVector.

In addition to a the vector, return a guard that ensures that the memory in slices is indeed mapped while in use. This guard must not be dropped while this vector is in use!

Trait Implementations§

Source§

impl Debug for IoVector<'_>

Source§

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

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

impl<'a> Default for IoVector<'a>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'a> From<&'a [u8]> for IoVector<'a>

Source§

fn from(slice: &'a [u8]) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<&'a IoBuffer> for IoVector<'a>

Source§

fn from(buf: &'a IoBuffer) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<&'a Vec<u8>> for IoVector<'a>

Source§

fn from(vec: &'a Vec<u8>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<IoBufferRef<'a>> for IoVector<'a>

Source§

fn from(buffer: IoBufferRef<'a>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<Vec<IoSlice<'a>>> for IoVector<'a>

Source§

fn from(vector: Vec<IoSlice<'a>>) -> Self

Converts to this type from the input type.
Source§

impl<'a> IoVectorTrait for IoVector<'a>

Source§

type SliceType = &'a [u8]

&[u8] or &mut [u8].
Source§

type BufferType = IoSlice<'a>

IoSlice or IoSliceMut.
Source§

fn new() -> Self

Create an empty vector.
Source§

fn with_capacity(cap: usize) -> Self

Create an empty vector, pre-allocating space for cap buffers. Read more
Source§

fn push(&mut self, slice: Self::SliceType)

Append a slice.
Source§

fn push_ioslice(&mut self, ioslice: Self::BufferType)

Append a slice.
Source§

fn insert(&mut self, index: usize, slice: Self::SliceType)

Insert a slice at the given index in the buffer vector.
Source§

fn len(&self) -> u64

Return the sum total length in bytes of all buffers in this vector.
Source§

fn buffer_count(&self) -> usize

Return the number of buffers in this vector.
Source§

fn append(&mut self, other: Self)

Append all buffers from the given other vector to this vector.
Source§

fn split_at(self, mid: u64) -> (Self, Self)

Split the vector into two. Read more
Source§

fn split_tail_at(self, mid: u64) -> Self

Like IoVectorTrait::split_at(), but discards the head, only returning the tail. Read more
Source§

fn copy_into_slice(&self, slice: &mut [u8])

Copy the data from self into slice. Read more
Source§

fn try_into_owned(self, alignment: usize) -> Result<IoBuffer>

Create a single owned IoBuffer with the same data (copied).
Source§

fn is_aligned(&self, mem_alignment: usize, req_alignment: usize) -> bool

Check whether self is aligned. Read more
Source§

fn into_inner(self) -> Vec<Self::BufferType>

Return the internal vector of IoSlice objects.
Source§

unsafe fn as_iovec<'b>(&'b self) -> &'b [iovec]
where Self: 'b,

Return a corresponding &[libc::iovec]. Read more
Source§

fn is_empty(&self) -> bool

Return true if and only if this vector’s length is zero. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for IoVector<'a>

§

impl<'a> RefUnwindSafe for IoVector<'a>

§

impl<'a> Send for IoVector<'a>

§

impl<'a> Sync for IoVector<'a>

§

impl<'a> Unpin for IoVector<'a>

§

impl<'a> UnwindSafe for IoVector<'a>

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more