Trait DataType

Source
pub trait DataType: Sized {
    const DATATYPE_MSGPCK: u8;
    const ARRAYDATATYPE_MSGPCK: u8;
    const DATATYPE_STRING: &'static str;
    const ARRAYDATATYPE_STRING: &'static str;

    // Required methods
    fn decode<R: RmpRead>(rd: &mut R) -> Result<Self, ()>;
    fn encode<W: RmpWrite>(wr: &mut W, val: Self) -> Result<(), ()>;

    // Provided methods
    fn decode_array<R: RmpRead>(rd: &mut R) -> Result<Vec<Self>, ()> { ... }
    fn encode_array<W: RmpWrite>(wr: &mut W, vals: Vec<Self>) -> Result<(), ()> { ... }
}

Required Associated Constants§

Required Methods§

Source

fn decode<R: RmpRead>(rd: &mut R) -> Result<Self, ()>

Source

fn encode<W: RmpWrite>(wr: &mut W, val: Self) -> Result<(), ()>

Provided Methods§

Source

fn decode_array<R: RmpRead>(rd: &mut R) -> Result<Vec<Self>, ()>

Source

fn encode_array<W: RmpWrite>(wr: &mut W, vals: Vec<Self>) -> Result<(), ()>

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 DataType for bool

Source§

const DATATYPE_MSGPCK: u8 = 0u8

Source§

const ARRAYDATATYPE_MSGPCK: u8 = 16u8

Source§

const DATATYPE_STRING: &'static str = "boolean"

Source§

const ARRAYDATATYPE_STRING: &'static str = "boolean[]"

Source§

fn decode<R: RmpRead>(rd: &mut R) -> Result<Self, ()>

Source§

fn encode<W: RmpWrite>(wr: &mut W, val: Self) -> Result<(), ()>

Source§

impl DataType for f32

Source§

const DATATYPE_MSGPCK: u8 = 3u8

Source§

const ARRAYDATATYPE_MSGPCK: u8 = 19u8

Source§

const DATATYPE_STRING: &'static str = "float"

Source§

const ARRAYDATATYPE_STRING: &'static str = "float[]"

Source§

fn decode<R: RmpRead>(rd: &mut R) -> Result<Self, ()>

Source§

fn encode<W: RmpWrite>(wr: &mut W, val: Self) -> Result<(), ()>

Source§

impl DataType for f64

Source§

const DATATYPE_MSGPCK: u8 = 1u8

Source§

const ARRAYDATATYPE_MSGPCK: u8 = 17u8

Source§

const DATATYPE_STRING: &'static str = "double"

Source§

const ARRAYDATATYPE_STRING: &'static str = "double[]"

Source§

fn decode<R: RmpRead>(rd: &mut R) -> Result<Self, ()>

Source§

fn encode<W: RmpWrite>(wr: &mut W, val: Self) -> Result<(), ()>

Source§

impl DataType for i32

Source§

const DATATYPE_MSGPCK: u8 = 2u8

Source§

const ARRAYDATATYPE_MSGPCK: u8 = 18u8

Source§

const DATATYPE_STRING: &'static str = "int"

Source§

const ARRAYDATATYPE_STRING: &'static str = "int[]"

Source§

fn decode<R: RmpRead>(rd: &mut R) -> Result<Self, ()>

Source§

fn encode<W: RmpWrite>(wr: &mut W, val: Self) -> Result<(), ()>

Source§

impl DataType for String

Source§

const DATATYPE_MSGPCK: u8 = 4u8

Source§

const ARRAYDATATYPE_MSGPCK: u8 = 20u8

Source§

const DATATYPE_STRING: &'static str = "string"

Source§

const ARRAYDATATYPE_STRING: &'static str = "string[]"

Source§

fn decode<R: RmpRead>(rd: &mut R) -> Result<Self, ()>

Source§

fn encode<W: RmpWrite>(wr: &mut W, val: Self) -> Result<(), ()>

Implementors§