pub trait ComputeMemory<F> {
type FSlice<'a>: Copy + SizedSlice + Sync;
type FSliceMut<'a>: SizedSlice;
const ALIGNMENT: usize;
Show 13 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 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>) { ... }
}
Expand description
Interface for manipulating handles to memory in a compute device.
Required Associated Constants§
Required Associated Types§
Sourcetype FSlice<'a>: Copy + SizedSlice + Sync
type FSlice<'a>: Copy + SizedSlice + Sync
An opaque handle to an immutable slice of elements stored in a compute memory.
Sourcetype FSliceMut<'a>: SizedSlice
type FSliceMut<'a>: SizedSlice
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 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
.
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.