logo
pub struct InOutBuf<'inp, 'out, T> { /* private fields */ }
Expand description

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

Implementations

Create InOutBuf from a single mutable reference.

Create InOutBuf from a pair of immutable and mutable references.

Create InOutBuf from immutable and mutable slices.

Returns an error if length of slices is not equal to each other.

Get length of the inner buffers.

Returns true if the buffer has a length of 0.

Returns InOut for given position.

Panics

If pos greater or equal to buffer length.

Get input slice.

Get output slice.

Consume self and return output slice with lifetime 'a.

Get raw input and output pointers.

Reborrow self.

Create InOutBuf 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 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 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 len * mem::size_of::<T>() must be no larger than isize::MAX.

Divides one buffer into two at mid index.

The first will contain all indices from [0, mid) (excluding the index mid itself) and the second will contain all indices from [mid, len) (excluding the index len itself).

Panics

Panics if mid > len.

Partition buffer into 2 parts: buffer of arrays and tail.

XORs data with values behind the input slice and write result to the output slice.

Panics

If data length is not equal to the buffer length.

Trait Implementations

Converts to this type from the input type.

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.