pub struct InOutBuf<'inp, 'out, T> { /* private fields */ }Expand description
A buffer that is read from and written to, which may or may not alias.
Drivers receive one of these for every cipher operation, covering both the in-place case (one buffer, encrypted in place) and the separate-buffer case (plaintext in one buffer, ciphertext to another) with a single entry point.
Implementations§
Source§impl<'inp, 'out, T> InOutBuf<'inp, 'out, T>
impl<'inp, 'out, T> InOutBuf<'inp, 'out, T>
Sourcepub fn new(
in_buf: &'inp [T],
out_buf: &'out mut [T],
) -> Result<Self, NotEqualError>
pub fn new( in_buf: &'inp [T], out_buf: &'out mut [T], ) -> Result<Self, NotEqualError>
Create an in/out buffer from separate input and output slices of equal length.
Sourcepub unsafe fn from_raw(in_ptr: *const T, out_ptr: *mut T, len: usize) -> Self
pub unsafe fn from_raw(in_ptr: *const T, out_ptr: *mut T, len: usize) -> Self
Construct from raw pointers.
§Safety
in_ptr must be valid for reads and out_ptr for writes of len
elements for the respective lifetimes. They may be equal; otherwise the
regions must not overlap.
Sourcepub fn is_in_place(&self) -> bool
pub fn is_in_place(&self) -> bool
Whether the input and output are the same buffer.
Sourcepub unsafe fn split(self) -> (&'inp [T], &'out mut [T])
pub unsafe fn split(self) -> (&'inp [T], &'out mut [T])
Split into the input and output slices.
When the buffer is in place, the returned slices alias. This is not
exposed as safe API for that reason; use get_in,
get_out or into_out_with_copied_in.
§Safety
The caller must not use both slices when is_in_place.
Sourcepub fn into_out_with_copied_in(self) -> &'out mut [T]where
T: Copy,
pub fn into_out_with_copied_in(self) -> &'out mut [T]where
T: Copy,
Return the output slice, after copying the input into it when they differ.
The natural entry point for drivers that only operate in place.
Sourcepub fn reborrow_range(
&mut self,
start: usize,
end: usize,
) -> InOutBuf<'_, '_, T>
pub fn reborrow_range( &mut self, start: usize, end: usize, ) -> InOutBuf<'_, '_, T>
Reborrow a sub-range of the buffer.