Trait npy::NpyRecord
[−]
[src]
pub trait NpyRecord: Sized { fn get_dtype() -> Vec<(&'static str, DType)>; fn n_bytes() -> usize; fn read(_: &[u8]) -> Self; fn write<W: Write>(&self, writer: &mut W) -> Result<()>; }
A trait representing a (de-)serializable data-structure.
If one wants to serialize a Vec<Foo>
, the Foo
must implement NpyRecord
.
This trait is often automatically implemented by a #[derive(NpyRecord)]
. This can be done
for a struct
where all fields implement Serializable
.
Required Methods
fn get_dtype() -> Vec<(&'static str, DType)>
Get a vector of pairs (field_name, DType) representing the struct type.
fn n_bytes() -> usize
Get the number of bytes of this record in the serialized representation
fn read(_: &[u8]) -> Self
Deserialize binary data to a single instance of Self
fn write<W: Write>(&self, writer: &mut W) -> Result<()>
Write Self in a binary form to a writer.