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>; }

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

Required methods

fn bytes_as_slice<'a>(
    bytes: &'a [u8],
    type_desc: &PyValue,
    len: usize
) -> Result<&'a [Self], ViewDataError>
[src]

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.

Loading content...

Implementations on Foreign Types

impl ViewElement for i8[src]

impl ViewElement for u8[src]

impl ViewElement for i16[src]

impl ViewElement for i32[src]

impl ViewElement for i64[src]

impl ViewElement for u16[src]

impl ViewElement for u32[src]

impl ViewElement for u64[src]

impl ViewElement for f32[src]

impl ViewElement for f64[src]

impl ViewElement for bool[src]

Loading content...

Implementors

Loading content...