Skip to main content

NpyType

Trait NpyType 

Source
pub trait NpyType: Copy {
    const DESCR: &'static str;
    const SIZE: usize;

    // Required methods
    fn write_le(self, buffer: &mut Vec<u8>);
    fn read_le(bytes: &[u8]) -> Self;

    // Provided methods
    fn read_from<R: Read>(file: &mut R, count: usize) -> Result<Vec<Self>> { ... }
    fn read_le_all(bytes: &[u8]) -> Vec<Self> { ... }
    fn write_le_all<W: Write>(data: &[Self], file: &mut W) -> Result<()> { ... }
    fn write_le_bytes(data: &[Self]) -> Vec<u8>  { ... }
}

Required Associated Constants§

Source

const DESCR: &'static str

Source

const SIZE: usize

Required Methods§

Source

fn write_le(self, buffer: &mut Vec<u8>)

Source

fn read_le(bytes: &[u8]) -> Self

Provided Methods§

Source

fn read_from<R: Read>(file: &mut R, count: usize) -> Result<Vec<Self>>

Source

fn read_le_all(bytes: &[u8]) -> Vec<Self>

Source

fn write_le_all<W: Write>(data: &[Self], file: &mut W) -> Result<()>

Source

fn write_le_bytes(data: &[Self]) -> Vec<u8>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl NpyType for f32

Source§

const DESCR: &'static str = "<f4"

Source§

const SIZE: usize

Source§

fn write_le(self, buffer: &mut Vec<u8>)

Source§

fn read_le(bytes: &[u8]) -> Self

Source§

impl NpyType for f64

Source§

const DESCR: &'static str = "<f8"

Source§

const SIZE: usize

Source§

fn write_le(self, buffer: &mut Vec<u8>)

Source§

fn read_le(bytes: &[u8]) -> Self

Source§

impl NpyType for i8

Source§

const DESCR: &'static str = "|i1"

Source§

const SIZE: usize

Source§

fn write_le(self, buffer: &mut Vec<u8>)

Source§

fn read_le(bytes: &[u8]) -> Self

Source§

impl NpyType for i16

Source§

const DESCR: &'static str = "<i2"

Source§

const SIZE: usize

Source§

fn write_le(self, buffer: &mut Vec<u8>)

Source§

fn read_le(bytes: &[u8]) -> Self

Source§

impl NpyType for i32

Source§

const DESCR: &'static str = "<i4"

Source§

const SIZE: usize

Source§

fn write_le(self, buffer: &mut Vec<u8>)

Source§

fn read_le(bytes: &[u8]) -> Self

Source§

impl NpyType for i64

Source§

const DESCR: &'static str = "<i8"

Source§

const SIZE: usize

Source§

fn write_le(self, buffer: &mut Vec<u8>)

Source§

fn read_le(bytes: &[u8]) -> Self

Source§

impl NpyType for u8

Source§

const DESCR: &'static str = "|u1"

Source§

const SIZE: usize

Source§

fn write_le(self, buffer: &mut Vec<u8>)

Source§

fn read_le(bytes: &[u8]) -> Self

Source§

impl NpyType for u16

Source§

const DESCR: &'static str = "<u2"

Source§

const SIZE: usize

Source§

fn write_le(self, buffer: &mut Vec<u8>)

Source§

fn read_le(bytes: &[u8]) -> Self

Source§

impl NpyType for u32

Source§

const DESCR: &'static str = "<u4"

Source§

const SIZE: usize

Source§

fn write_le(self, buffer: &mut Vec<u8>)

Source§

fn read_le(bytes: &[u8]) -> Self

Source§

impl NpyType for u64

Source§

const DESCR: &'static str = "<u8"

Source§

const SIZE: usize

Source§

fn write_le(self, buffer: &mut Vec<u8>)

Source§

fn read_le(bytes: &[u8]) -> Self

Implementors§