Trait ndarray_npy::ViewElement[][src]

pub trait ViewElement: Sized {
    fn bytes_as_slice<'a>(
        bytes: &'a [u8],
        type_desc: &PyValue,
        len: usize
    ) -> Result<&'a [Self], ViewDataError>; }
Expand description

An array element type that can be viewed (without copying) in an .npy file.

Required methods

Casts bytes into a slice of elements of length len.

Returns Err(_) in at least the following cases:

  • if the type_desc does not match Self with native endianness
  • if the bytes slice is misaligned for elements of type Self
  • if the bytes slice is too short for len elements
  • if the bytes slice has extra bytes after len elements

May panic if len * size_of::<Self>() overflows.

Implementations on Foreign Types

Implementors