Skip to main content

AsRawBuffer

Trait AsRawBuffer 

Source
pub trait AsRawBuffer {
    // Required methods
    fn raw_ptr(&self) -> *const u8;
    fn raw_shape(&self) -> &[usize];
    fn raw_strides_bytes(&self) -> Vec<isize>;
    fn raw_dtype(&self) -> DType;
    fn is_c_contiguous(&self) -> bool;
    fn is_f_contiguous(&self) -> bool;
}
Expand description

Trait exposing the raw memory layout of an array for zero-copy interop.

Implementors provide enough information for foreign code (C, Python/NumPy, Arrow, etc.) to read the array data without copying.

Required Methods§

Source

fn raw_ptr(&self) -> *const u8

Raw pointer to the first element.

Source

fn raw_shape(&self) -> &[usize]

Shape as a slice of dimension sizes.

Source

fn raw_strides_bytes(&self) -> Vec<isize>

Strides in bytes (not elements).

Source

fn raw_dtype(&self) -> DType

Runtime dtype descriptor.

Source

fn is_c_contiguous(&self) -> bool

Whether the data is C-contiguous.

Source

fn is_f_contiguous(&self) -> bool

Whether the data is Fortran-contiguous.

Implementors§