pub trait ComputeMemory<F> {
type FSlice<'a>: Copy + SizedSlice + Send + Sync + Debug;
type FSliceMut<'a>: SizedSlice + Send + Debug;
const ALIGNMENT: usize;
Show 15 methods
// Required methods
fn narrow<'a>(data: &'a Self::FSlice<'_>) -> Self::FSlice<'a>;
fn narrow_mut<'a, 'b: 'a>(data: Self::FSliceMut<'b>) -> Self::FSliceMut<'a>;
fn to_owned_mut<'a>(
data: &'a mut Self::FSliceMut<'_>,
) -> Self::FSliceMut<'a>;
fn as_const<'a>(data: &'a Self::FSliceMut<'_>) -> Self::FSlice<'a>;
fn to_const(data: Self::FSliceMut<'_>) -> Self::FSlice<'_>;
fn slice(
data: Self::FSlice<'_>,
range: impl RangeBounds<usize>,
) -> Self::FSlice<'_>;
fn slice_mut<'a>(
data: &'a mut Self::FSliceMut<'_>,
range: impl RangeBounds<usize>,
) -> Self::FSliceMut<'a>;
fn split_at_mut(
data: Self::FSliceMut<'_>,
mid: usize,
) -> (Self::FSliceMut<'_>, Self::FSliceMut<'_>);
fn slice_chunks_mut<'a>(
data: Self::FSliceMut<'a>,
chunk_len: usize,
) -> impl Iterator<Item = Self::FSliceMut<'a>>;
// Provided methods
fn split_at(
data: Self::FSlice<'_>,
mid: usize,
) -> (Self::FSlice<'_>, Self::FSlice<'_>) { ... }
fn split_at_mut_borrowed<'a>(
data: &'a mut Self::FSliceMut<'_>,
mid: usize,
) -> (Self::FSliceMut<'a>, Self::FSliceMut<'a>) { ... }
fn slice_chunks<'a>(
data: Self::FSlice<'a>,
chunk_len: usize,
) -> impl Iterator<Item = Self::FSlice<'a>> { ... }
fn split_half<'a>(
data: Self::FSlice<'a>,
) -> (Self::FSlice<'a>, Self::FSlice<'a>) { ... }
fn split_half_mut<'a>(
data: Self::FSliceMut<'a>,
) -> (Self::FSliceMut<'a>, Self::FSliceMut<'a>) { ... }
fn slice_power_of_two_mut<'a>(
input: &'a mut Self::FSliceMut<'_>,
n: usize,
) -> Self::FSliceMut<'a> { ... }
}
Expand description
Interface for manipulating handles to memory in a compute device.
Required Associated Constants§
Required Associated Types§
Sourcetype FSlice<'a>: Copy + SizedSlice + Send + Sync + Debug
type FSlice<'a>: Copy + SizedSlice + Send + Sync + Debug
An opaque handle to an immutable slice of elements stored in a compute memory.
Sourcetype FSliceMut<'a>: SizedSlice + Send + Debug
type FSliceMut<'a>: SizedSlice + Send + Debug
An opaque handle to a mutable slice of elements stored in a compute memory.
Required Methods§
Sourcefn narrow<'a>(data: &'a Self::FSlice<'_>) -> Self::FSlice<'a>
fn narrow<'a>(data: &'a Self::FSlice<'_>) -> Self::FSlice<'a>
Borrows an immutable memory slice, narrowing the lifetime.
Sourcefn narrow_mut<'a, 'b: 'a>(data: Self::FSliceMut<'b>) -> Self::FSliceMut<'a>
fn narrow_mut<'a, 'b: 'a>(data: Self::FSliceMut<'b>) -> Self::FSliceMut<'a>
Borrows a mutable memory slice, narrowing the lifetime.
fn to_owned_mut<'a>(data: &'a mut Self::FSliceMut<'_>) -> Self::FSliceMut<'a>
Sourcefn as_const<'a>(data: &'a Self::FSliceMut<'_>) -> Self::FSlice<'a>
fn as_const<'a>(data: &'a Self::FSliceMut<'_>) -> Self::FSlice<'a>
Borrows a mutable memory slice as immutable.
This allows the immutable reference to be copied.
Sourcefn to_const(data: Self::FSliceMut<'_>) -> Self::FSlice<'_>
fn to_const(data: Self::FSliceMut<'_>) -> Self::FSlice<'_>
Converts a mutable memory slice to an immutable slice.
Sourcefn slice(
data: Self::FSlice<'_>,
range: impl RangeBounds<usize>,
) -> Self::FSlice<'_>
fn slice( data: Self::FSlice<'_>, range: impl RangeBounds<usize>, ) -> Self::FSlice<'_>
Borrows a subslice of an immutable memory slice.
§Preconditions
- the range bounds must be multiples of
Self::ALIGNMENT
Sourcefn slice_mut<'a>(
data: &'a mut Self::FSliceMut<'_>,
range: impl RangeBounds<usize>,
) -> Self::FSliceMut<'a>
fn slice_mut<'a>( data: &'a mut Self::FSliceMut<'_>, range: impl RangeBounds<usize>, ) -> Self::FSliceMut<'a>
Borrows a subslice of a mutable memory slice.
§Preconditions
- the range bounds must be multiples of
Self::ALIGNMENT
Sourcefn split_at_mut(
data: Self::FSliceMut<'_>,
mid: usize,
) -> (Self::FSliceMut<'_>, Self::FSliceMut<'_>)
fn split_at_mut( data: Self::FSliceMut<'_>, mid: usize, ) -> (Self::FSliceMut<'_>, Self::FSliceMut<'_>)
Splits a mutable slice into two disjoint subslices.
§Preconditions
mid
must be a multiple ofSelf::ALIGNMENT
Sourcefn slice_chunks_mut<'a>(
data: Self::FSliceMut<'a>,
chunk_len: usize,
) -> impl Iterator<Item = Self::FSliceMut<'a>>
fn slice_chunks_mut<'a>( data: Self::FSliceMut<'a>, chunk_len: usize, ) -> impl Iterator<Item = Self::FSliceMut<'a>>
Splits a mutable slice into equal chunks.
§Preconditions
- the length of the slice must be a multiple of
chunk_len
chunk_len
must be a multiple ofSelf::ALIGNMENT
Provided Methods§
Sourcefn split_at(
data: Self::FSlice<'_>,
mid: usize,
) -> (Self::FSlice<'_>, Self::FSlice<'_>)
fn split_at( data: Self::FSlice<'_>, mid: usize, ) -> (Self::FSlice<'_>, Self::FSlice<'_>)
Splits an immutable slice into two disjoint subslices.
§Preconditions
mid
must be a multiple ofSelf::ALIGNMENT
fn split_at_mut_borrowed<'a>( data: &'a mut Self::FSliceMut<'_>, mid: usize, ) -> (Self::FSliceMut<'a>, Self::FSliceMut<'a>)
Sourcefn slice_chunks<'a>(
data: Self::FSlice<'a>,
chunk_len: usize,
) -> impl Iterator<Item = Self::FSlice<'a>>
fn slice_chunks<'a>( data: Self::FSlice<'a>, chunk_len: usize, ) -> impl Iterator<Item = Self::FSlice<'a>>
Splits slice into equal chunks.
§Preconditions
- the length of the slice must be a multiple of
chunk_len
chunk_len
must be a multiple ofSelf::ALIGNMENT
Sourcefn split_half<'a>(
data: Self::FSlice<'a>,
) -> (Self::FSlice<'a>, Self::FSlice<'a>)
fn split_half<'a>( data: Self::FSlice<'a>, ) -> (Self::FSlice<'a>, Self::FSlice<'a>)
Splits an immutable slice of power-two length into two equal halves.
Unlike all other splitting methods, this method does not require input or output slices
to be a multiple of Self::ALIGNMENT
.
Sourcefn split_half_mut<'a>(
data: Self::FSliceMut<'a>,
) -> (Self::FSliceMut<'a>, Self::FSliceMut<'a>)
fn split_half_mut<'a>( data: Self::FSliceMut<'a>, ) -> (Self::FSliceMut<'a>, Self::FSliceMut<'a>)
Splits a mutable slice of power-two length into two equal halves.
Unlike all other splitting methods, this method does not require input or output slices
to be a multiple of Self::ALIGNMENT
.
Sourcefn slice_power_of_two_mut<'a>(
input: &'a mut Self::FSliceMut<'_>,
n: usize,
) -> Self::FSliceMut<'a>
fn slice_power_of_two_mut<'a>( input: &'a mut Self::FSliceMut<'_>, n: usize, ) -> Self::FSliceMut<'a>
Slices off the first n
elements, mutably, where n
is a power of two.
§Arguments
input
- The input slice to be trimmedn
- The length of the requested subslice
§Pre-conditions
n
is a power of two
§Returns
A mutable slice with the first n
elements. If the input is smaller than n
, this returns
the whole input.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.