Trait coap_message::numtraits::Ux[][src]

pub trait Ux: Sealed + Copy + Clone {
    type Bytes: AsRef<[u8]> + Default + AsMut<[u8]>;
    fn to_be_bytes(self) -> Self::Bytes;
fn from_be_bytes(bytes: Self::Bytes) -> Self; }

Trait for any integer type that can be converted to a number of octets in network byte order for CoAP.

These are used to back the crate::MinimalWritableMessage::add_option_uint functions.

Implemented as a sealed trait over u8, u16, u32 and u64 to be later moved to num_traits::PrimInt if https://github.com/rust-num/num-traits/issues/189 works out, or a similar generic trait.

Associated Types

type Bytes: AsRef<[u8]> + Default + AsMut<[u8]>[src]

Index is used to get a slice out of it, Default and IndexMut in value_uint. Given it's sealed, this can easily be extended if the add_option_uint or value_uint implementations chanage.

Loading content...

Required methods

fn to_be_bytes(self) -> Self::Bytes[src]

fn from_be_bytes(bytes: Self::Bytes) -> Self[src]

Loading content...

Implementors

impl Ux for u8[src]

type Bytes = [u8; 1]

impl Ux for u16[src]

type Bytes = [u8; 2]

impl Ux for u32[src]

type Bytes = [u8; 4]

impl Ux for u64[src]

type Bytes = [u8; 8]

Loading content...