Struct inout::InOutBufReserved

source ·
pub struct InOutBufReserved<'inp, 'out, T> { /* private fields */ }
Expand description

Custom slice type which references one immutable (input) slice and one mutable (output) slice. Input and output slices are either the same or do not overlap. Length of the output slice is always equal or bigger than length of the input slice.

Implementations§

source§

impl<'a, T> InOutBufReserved<'a, 'a, T>

source

pub fn from_mut_slice( buf: &'a mut [T], msg_len: usize, ) -> Result<Self, OutIsTooSmallError>

Crate InOutBufReserved from a single mutable slice.

source

pub unsafe fn from_raw( in_ptr: *const T, in_len: usize, out_ptr: *mut T, out_len: usize, ) -> Self

Create InOutBufReserved from raw input and output pointers.

§Safety

Behavior is undefined if any of the following conditions are violated:

  • in_ptr must point to a properly initialized value of type T and must be valid for reads for in_len * mem::size_of::<T>() many bytes.
  • out_ptr must point to a properly initialized value of type T and must be valid for both reads and writes for out_len * mem::size_of::<T>() many bytes.
  • in_ptr and out_ptr must be either equal or non-overlapping.
  • If in_ptr and out_ptr are equal, then the memory referenced by them must not be accessed through any other pointer (not derived from the return value) for the duration of lifetime ’a. Both read and write accesses are forbidden.
  • If in_ptr and out_ptr are not equal, then the memory referenced by out_ptr must not be accessed through any other pointer (not derived from the return value) for the duration of lifetime ’a. Both read and write accesses are forbidden. The memory referenced by in_ptr must not be mutated for the duration of lifetime 'a, except inside an UnsafeCell.
  • The total size in_len * mem::size_of::<T>() and out_len * mem::size_of::<T>() must be no larger than isize::MAX.
source

pub fn into_raw(self) -> (*const T, *mut T)

Get raw input and output pointers.

source

pub fn get_in_len(&self) -> usize

Get input buffer length.

source

pub fn get_out_len(&self) -> usize

Get output buffer length.

source§

impl<'inp, 'out, T> InOutBufReserved<'inp, 'out, T>

source

pub fn from_slices( in_buf: &'inp [T], out_buf: &'out mut [T], ) -> Result<Self, OutIsTooSmallError>

Crate InOutBufReserved from two separate slices.

source

pub fn get_in<'a>(&'a self) -> &'a [T]

Get input slice.

source

pub fn get_out<'a>(&'a mut self) -> &'a mut [T]

Get output slice.

Auto Trait Implementations§

§

impl<'inp, 'out, T> Freeze for InOutBufReserved<'inp, 'out, T>

§

impl<'inp, 'out, T> RefUnwindSafe for InOutBufReserved<'inp, 'out, T>
where T: RefUnwindSafe,

§

impl<'inp, 'out, T> !Send for InOutBufReserved<'inp, 'out, T>

§

impl<'inp, 'out, T> !Sync for InOutBufReserved<'inp, 'out, T>

§

impl<'inp, 'out, T> Unpin for InOutBufReserved<'inp, 'out, T>

§

impl<'inp, 'out, T> !UnwindSafe for InOutBufReserved<'inp, 'out, T>

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> Same for T

source§

type Output = T

Should always be Self
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.