DmapType

Trait DmapType 

Source
pub trait DmapType: Debug {
    // Required methods
    fn size() -> usize
       where Self: Sized;
    fn as_bytes(&self) -> Vec<u8> ;
    fn from_bytes(bytes: &[u8]) -> Result<Self, DmapError>
       where Self: Sized;
    fn dmap_type() -> Type;
}
Expand description

Trait for raw types that can be stored in DMAP files.

Required Methods§

Source

fn size() -> usize
where Self: Sized,

Size in bytes of the type.

Source

fn as_bytes(&self) -> Vec<u8>

Create a copy of the data as raw bytes.

Source

fn from_bytes(bytes: &[u8]) -> Result<Self, DmapError>
where Self: Sized,

Convert raw bytes to Self

§Errors

If the bytes are not a valid DMAP record of type Self.

Source

fn dmap_type() -> Type

Get the Type variant that represents self

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 DmapType for f32

Source§

fn size() -> usize

Source§

fn as_bytes(&self) -> Vec<u8>

Source§

fn from_bytes(bytes: &[u8]) -> Result<Self, DmapError>
where Self: Sized,

Source§

fn dmap_type() -> Type

Source§

impl DmapType for f64

Source§

fn size() -> usize

Source§

fn as_bytes(&self) -> Vec<u8>

Source§

fn from_bytes(bytes: &[u8]) -> Result<Self, DmapError>
where Self: Sized,

Source§

fn dmap_type() -> Type

Source§

impl DmapType for i8

Source§

fn size() -> usize

Source§

fn as_bytes(&self) -> Vec<u8>

Source§

fn from_bytes(bytes: &[u8]) -> Result<Self, DmapError>
where Self: Sized,

Source§

fn dmap_type() -> Type

Source§

impl DmapType for i16

Source§

fn size() -> usize

Source§

fn as_bytes(&self) -> Vec<u8>

Source§

fn from_bytes(bytes: &[u8]) -> Result<Self, DmapError>
where Self: Sized,

Source§

fn dmap_type() -> Type

Source§

impl DmapType for i32

Source§

fn size() -> usize

Source§

fn as_bytes(&self) -> Vec<u8>

Source§

fn from_bytes(bytes: &[u8]) -> Result<Self, DmapError>
where Self: Sized,

Source§

fn dmap_type() -> Type

Source§

impl DmapType for i64

Source§

fn size() -> usize

Source§

fn as_bytes(&self) -> Vec<u8>

Source§

fn from_bytes(bytes: &[u8]) -> Result<Self, DmapError>
where Self: Sized,

Source§

fn dmap_type() -> Type

Source§

impl DmapType for u8

Source§

fn size() -> usize

Source§

fn as_bytes(&self) -> Vec<u8>

Source§

fn from_bytes(bytes: &[u8]) -> Result<Self, DmapError>
where Self: Sized,

Source§

fn dmap_type() -> Type

Source§

impl DmapType for u16

Source§

fn size() -> usize

Source§

fn as_bytes(&self) -> Vec<u8>

Source§

fn from_bytes(bytes: &[u8]) -> Result<Self, DmapError>
where Self: Sized,

Source§

fn dmap_type() -> Type

Source§

impl DmapType for u32

Source§

fn size() -> usize

Source§

fn as_bytes(&self) -> Vec<u8>

Source§

fn from_bytes(bytes: &[u8]) -> Result<Self, DmapError>
where Self: Sized,

Source§

fn dmap_type() -> Type

Source§

impl DmapType for u64

Source§

fn size() -> usize

Source§

fn as_bytes(&self) -> Vec<u8>

Source§

fn from_bytes(bytes: &[u8]) -> Result<Self, DmapError>
where Self: Sized,

Source§

fn dmap_type() -> Type

Source§

impl DmapType for String

Implementors§