Struct inout::reserved::InOutBufReserved
source · pub struct InOutBufReserved<'inp, 'out, T> {
in_ptr: *const T,
out_ptr: *mut T,
in_len: usize,
out_len: usize,
_pd: PhantomData<(&'inp T, &'out mut T)>,
}
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.
Fields§
§in_ptr: *const T
§out_ptr: *mut T
§in_len: usize
§out_len: usize
§_pd: PhantomData<(&'inp T, &'out mut T)>
Implementations§
source§impl<'a, T> InOutBufReserved<'a, 'a, T>
impl<'a, T> InOutBufReserved<'a, 'a, T>
sourcepub fn from_mut_slice(
buf: &'a mut [T],
msg_len: usize,
) -> Result<Self, OutIsTooSmallError>
pub fn from_mut_slice( buf: &'a mut [T], msg_len: usize, ) -> Result<Self, OutIsTooSmallError>
Crate InOutBufReserved
from a single mutable slice.
sourcepub unsafe fn from_raw(
in_ptr: *const T,
in_len: usize,
out_ptr: *mut T,
out_len: usize,
) -> Self
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 typeT
and must be valid for reads forin_len * mem::size_of::<T>()
many bytes.out_ptr
must point to a properly initialized value of typeT
and must be valid for both reads and writes forout_len * mem::size_of::<T>()
many bytes.in_ptr
andout_ptr
must be either equal or non-overlapping.- If
in_ptr
andout_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
andout_ptr
are not equal, then the memory referenced byout_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 byin_ptr
must not be mutated for the duration of lifetime'a
, except inside anUnsafeCell
. - The total size
in_len * mem::size_of::<T>()
andout_len * mem::size_of::<T>()
must be no larger thanisize::MAX
.
sourcepub fn get_in_len(&self) -> usize
pub fn get_in_len(&self) -> usize
Get input buffer length.
sourcepub fn get_out_len(&self) -> usize
pub fn get_out_len(&self) -> usize
Get output buffer length.
source§impl<'inp, 'out, T> InOutBufReserved<'inp, 'out, T>
impl<'inp, 'out, T> InOutBufReserved<'inp, 'out, T>
sourcepub fn from_slices(
in_buf: &'inp [T],
out_buf: &'out mut [T],
) -> Result<Self, OutIsTooSmallError>
pub fn from_slices( in_buf: &'inp [T], out_buf: &'out mut [T], ) -> Result<Self, OutIsTooSmallError>
Crate InOutBufReserved
from two separate slices.
source§impl<'inp, 'out> InOutBufReserved<'inp, 'out, u8>
impl<'inp, 'out> InOutBufReserved<'inp, 'out, u8>
sourcepub fn into_padded_blocks<P, BS>(
self,
) -> Result<PaddedInOutBuf<'inp, 'out, BS>, PadError>
pub fn into_padded_blocks<P, BS>( self, ) -> Result<PaddedInOutBuf<'inp, 'out, BS>, PadError>
Transform buffer into PaddedInOutBuf
using padding algorithm P
.
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more