[][src]Struct ioslice::IoBox

#[repr(transparent)]pub struct IoBox<I: Initialization = Initialized> { /* fields omitted */ }

An owned chunk of memory, that is ABI-compatible with libc::iovec. At the moment this does not work on Windows.

This must be allocated via the system alloc; importing pointers from malloc(2) is currently not possible.

Implementations

impl<I: Initialization> IoBox<I>[src]

pub fn try_alloc_zeroed(length: usize) -> Result<Self, AllocationError>[src]

Attempt to allocate length bytes, which are initially set to zero.

This allocation may fail, but should not be used unless the global allocator actually does return null when there is no memory. This is generally not the case for userspace processes, where the kernel gives more memory than physically available, but is obviously useful in #![no_std].

Since the allocator may be able to already have zeroed blocks of memory, this should be preferred over manually initializing it using zeroed.

pub fn alloc_zeroed(length: usize) -> Self[src]

Allocate length bytes, which are initially set to zero.

Panics

This method will, like most other heap-allocated structures in the alloc crate, panic when there is no available memory left.

pub fn into_raw_parts(self) -> (*mut u8, usize)[src]

Turn the I/O box into the underlying pointer and size.

pub unsafe fn from_raw_parts(base: *mut u8, len: usize) -> Self[src]

Convert an underlying pointer and size, into an IoBox.

Safety

For this to be safe, the validity and initialization invariants must be held. In addition to that, the pointer must be allocated using the system allocator.

pub fn into_iovec(self) -> iovec[src]

pub fn into_box(self) -> Box<[u8]>[src]

pub fn as_ioslice(&self) -> IoSlice<'_, I>[src]

pub fn as_ioslice_mut(&mut self) -> IoSliceMut<'_, I>[src]

pub fn inner_data(&self) -> &[I::DerefTargetItem][src]

pub fn inner_data_mut(&mut self) -> &mut [I::DerefTargetItem][src]

pub fn slice_as_ioslices(these: &[Self]) -> &[IoSlice<'_>][src]

pub fn slice_as_ioslices_mut(these: &mut [Self]) -> &mut [IoSlice<'_>][src]

pub fn slice_as_mut_ioslices(these: &[Self]) -> &[IoSliceMut<'_>][src]

pub fn slice_as_mut_ioslices_mut(these: &mut [Self]) -> &mut [IoSliceMut<'_>][src]

pub unsafe fn assume_init(self) -> IoBox<Initialized>[src]

Convert IoBox<_> into IoBox<Initialized>, assuming that the data is initialized.

Safety

This shall not be used for initializing data. In that case, initialize it manually via as_maybe_uninit_slice_mut, and then call this.

While the validity invariant is already upheld when creating this type, the caller must ensure that the data be initialized. Refer to the std::mem::MaybeUninit docs.

pub fn as_maybe_uninit_slice(&self) -> &[MaybeUninit<u8>][src]

pub fn as_maybe_uninit_slice_mut(&mut self) -> &mut [MaybeUninit<u8>][src]

pub fn zeroed(self) -> IoBox<Initialized>[src]

pub fn try_alloc_uninit(
    length: usize
) -> Result<IoBox<Uninitialized>, AllocationError>
[src]

pub fn alloc_uninit(length: usize) -> IoBox<Uninitialized>[src]

impl IoBox<Initialized>[src]

pub fn as_slice(&self) -> &[u8][src]

pub fn as_slice_mut(&mut self) -> &mut [u8][src]

Trait Implementations

impl AsMut<[u8]> for IoBox[src]

impl AsRef<[u8]> for IoBox[src]

impl Borrow<[u8]> for IoBox[src]

impl BorrowMut<[u8]> for IoBox[src]

impl Debug for IoBox[src]

impl Deref for IoBox[src]

type Target = [u8]

The resulting type after dereferencing.

impl DerefMut for IoBox[src]

impl<I: Initialization> Drop for IoBox<I>[src]

impl Eq for IoBox[src]

impl From<Box<[u8]>> for IoBox[src]

impl From<IoBox<Initialized>> for Box<[u8]>[src]

impl From<IoBox<Initialized>> for Vec<u8>[src]

impl From<Vec<u8>> for IoBox[src]

impl PartialEq<[u8]> for IoBox[src]

impl PartialEq<IoBox<Initialized>> for IoBox[src]

impl<'a> PartialEq<IoSlice<'a, Initialized>> for IoBox[src]

impl<'a> PartialEq<IoSliceMut<'a, Initialized>> for IoBox[src]

Auto Trait Implementations

impl<I> RefUnwindSafe for IoBox<I> where
    I: RefUnwindSafe

impl<I = Initialized> !Send for IoBox<I>

impl<I = Initialized> !Sync for IoBox<I>

impl<I> Unpin for IoBox<I> where
    I: Unpin

impl<I> UnwindSafe for IoBox<I> where
    I: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.