Trait npy::Serializable
[−]
[src]
pub trait Serializable: Sized { fn dtype() -> DType; fn n_bytes() -> usize; fn read(c: &[u8]) -> Self; fn write<W: Write>(&self, writer: &mut W) -> Result<()>; }
This trait contains information on how to serialize and deserialize a type.
An example illustrating a Serializable
implementation for a fixed-size vector is in
the roundtrip test.
It is strongly advised to annotate the Serializable
functions as #[inline]
for good
performance.
Required Methods
fn dtype() -> DType
Convert a type to a structure representing a Numpy type
fn n_bytes() -> usize
Get the number of bytes of the binary repr
fn read(c: &[u8]) -> Self
Deserialize a single data field, advancing the cursor in the process.
fn write<W: Write>(&self, writer: &mut W) -> Result<()>
Serialize a single data field into a writer.