Trait Sample

Source
pub trait Sample:
    Copy
    + Default
    + Send
    + Sync
    + 'static {
    type Type;

    // Required methods
    fn size() -> usize;
    fn parse(data: &[u8]) -> Result<Self::Type>;
    fn serialize(&self) -> Vec<u8> ;
}
Expand description

A trait all sample types must implement.

Required Associated Types§

Source

type Type

The type of the sample.

Required Methods§

Source

fn size() -> usize

The serialized size of one sample.

Source

fn parse(data: &[u8]) -> Result<Self::Type>

Parse one sample.

Source

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

Serialize one sample.

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 Sample for i32

Source§

type Type = i32

Source§

fn size() -> usize

Source§

fn parse(data: &[u8]) -> Result<Self::Type>

Source§

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

Source§

impl Sample for u8

Source§

type Type = u8

Source§

fn size() -> usize

Source§

fn parse(data: &[u8]) -> Result<Self::Type>

Source§

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

Source§

impl Sample for u32

Source§

type Type = u32

Source§

fn size() -> usize

Source§

fn parse(data: &[u8]) -> Result<Self::Type>

Source§

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

Implementors§