Skip to main content

ArrayProtocol

Trait ArrayProtocol 

Source
pub trait ArrayProtocol {
    // Required methods
    fn array_interface(&self) -> ArrayInterfaceDict;
    fn dtype_str(&self) -> &'static str;
    fn shape(&self) -> Vec<usize>;
    fn strides(&self) -> Vec<usize>;
    fn data_ptr(&self) -> *const u8;
    fn nbytes(&self) -> usize;
}
Expand description

Mixin trait for types that support the NumPy array interface protocol.

Implementors must provide shape, stride, type-string, and a raw data pointer, from which a complete ArrayInterfaceDict can be assembled.

Required Methods§

Source

fn array_interface(&self) -> ArrayInterfaceDict

Returns the populated ArrayInterfaceDict for this object.

Source

fn dtype_str(&self) -> &'static str

Returns the NumPy dtype type-string (e.g. "<f8" for little-endian f64).

Source

fn shape(&self) -> Vec<usize>

Returns the logical shape of the array.

Source

fn strides(&self) -> Vec<usize>

Returns the strides of the array in bytes.

Source

fn data_ptr(&self) -> *const u8

Returns a raw pointer to the first byte of element data.

Source

fn nbytes(&self) -> usize

Returns the total number of bytes occupied by the element buffer.

Implementors§