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;

    // Provided method
    fn buffer_descriptor(&self) -> BufferDescriptor<'_> { ... }
}
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.

Provided Methods§

Source

fn buffer_descriptor(&self) -> BufferDescriptor<'_>

Build a BufferDescriptor aggregating every field above into a single FFI-safe struct (#358). Default impl composes the other trait methods so concrete types don’t need to override.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<'a, T: Element, D: Dimension> AsRawBuffer for ArrayView<'a, T, D>

Source§

impl<T: Element, D: Dimension> AsRawBuffer for ArcArray<T, D>

Source§

impl<T: Element, D: Dimension> AsRawBuffer for Array<T, D>