#[repr(C)]pub struct BufferDescriptor<'a> {
pub data: *const u8,
pub ndim: usize,
pub shape: &'a [usize],
pub strides_bytes: Box<[isize]>,
pub dtype: DType,
pub itemsize: usize,
pub c_contiguous: bool,
pub f_contiguous: bool,
}Expand description
FFI-safe descriptor for an array’s memory layout (#358).
Mirrors the fields C and Python’s PEP 3118 buffer protocol carry:
data pointer, dtype tag, ndim, plus pointers to shape and strides
arrays. The struct is repr(C) so it can cross an FFI boundary
directly — caller is responsible for ensuring the originating
array outlives the descriptor (the pointers borrow into the
array’s storage; ferray does not extend the array’s lifetime).
Strides are in bytes, matching numpy’s PyArrayObject and the
PEP 3118 convention. The shape and strides slices are alive for
as long as the originating array (typically 'static for
Array<T, D> storage and 'a for views).
Fields§
§data: *const u8Pointer to the first element of the array.
ndim: usizeNumber of axes.
shape: &'a [usize]Shape (length ndim).
strides_bytes: Box<[isize]>Strides in bytes (length ndim). Matches numpy / PEP 3118.
dtype: DTypeElement type tag.
itemsize: usizeElement size in bytes (redundant with dtype.size_of() but
surfaced here so foreign code doesn’t need a DType match).
c_contiguous: boolWhether the data is laid out in C-contiguous (row-major) order.
f_contiguous: boolWhether the data is laid out in F-contiguous (column-major) order.
Trait Implementations§
Source§impl<'a> Clone for BufferDescriptor<'a>
impl<'a> Clone for BufferDescriptor<'a>
Source§fn clone(&self) -> BufferDescriptor<'a>
fn clone(&self) -> BufferDescriptor<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more