BitfieldSerialize

Trait BitfieldSerialize 

Source
pub trait BitfieldSerialize {
    // Required methods
    fn serialize(&self) -> Vec<u8> ;
    fn deserialize(data: &[u8]) -> Result<Self, String>
       where Self: Sized;

    // Provided methods
    fn to_hex(&self) -> String { ... }
    fn from_hex(hex_str: &str) -> Result<Self, String>
       where Self: Sized { ... }
}
Expand description

Trait for serializing and deserializing bitfield structures.

Required Methods§

Source

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

Serialize the bitfield to a byte vector.

Source

fn deserialize(data: &[u8]) -> Result<Self, String>
where Self: Sized,

Deserialize a bitfield from a byte slice.

Provided Methods§

Source

fn to_hex(&self) -> String

Serialize to a hexadecimal string.

Source

fn from_hex(hex_str: &str) -> Result<Self, String>
where Self: Sized,

Deserialize from a hexadecimal string.

Implementations on Foreign Types§

Source§

impl BitfieldSerialize for u8

Source§

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

Source§

fn deserialize(data: &[u8]) -> Result<Self, String>

Source§

impl BitfieldSerialize for u16

Source§

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

Source§

fn deserialize(data: &[u8]) -> Result<Self, String>

Source§

impl BitfieldSerialize for u32

Source§

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

Source§

fn deserialize(data: &[u8]) -> Result<Self, String>

Source§

impl BitfieldSerialize for u64

Source§

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

Source§

fn deserialize(data: &[u8]) -> Result<Self, String>

Implementors§