Trait npyz::Deserialize[][src]

pub trait Deserialize: Sized {
    type TypeReader: TypeRead<Value = Self>;
    fn reader(dtype: &DType) -> Result<Self::TypeReader, DTypeError>;
}
Expand description

Trait that permits reading a type from an .npy file.

Examples of types that implement this:

  • Primitive integers, floats, Complex (with the "complex" feature)
  • Owned byte containers (Vec<u8>)

This trait is derivable when enabling the "derive" feature. This makes it easier to work with structured arrays.

For an example of how to implement this manually, see Vector5 in the roundtrip test.

Associated Types

Think of this as like a for<R: io::Read> Fn(R) -> io::Result<Self>.

There is no closure-like sugar for these; you must manually define a type that implements TypeRead.

Required methods

Get a function that deserializes a single data field at a time.

The purpose of the dtype arugment is to allow e.g. specifying a length for string types, or the endianness for integers.

Errors

Returns Err if the DType is not compatible with Self.

Implementations on Foreign Types

This impl is only available with the complex feature.

This impl is only available with the complex feature.

Implementors