Trait Packable

Source
pub trait Packable:
    PartialEq
    + Debug
    + ToOwned<Owned: Debug + Clone + PartialEq>
    + PartialOrd {
    // Required methods
    fn width(item: &Self) -> usize;
    fn pack(item: &Self, out: &mut Vec<u8>);
    fn unpack(buff: &[u8]) -> Result<(usize, Cow<'_, Self>), PackError>;

    // Provided methods
    fn abs(_item: &Self) -> i64 { ... }
    fn agg(_item: &Self) -> Agg { ... }
    fn maybe_agg(_item: &Option<Cow<'_, Self>>) -> Agg { ... }
    fn validate(_val: Option<&Self>, _m: &ScanMeta) -> Result<(), PackError> { ... }
}

Required Methods§

Source

fn width(item: &Self) -> usize

Source

fn pack(item: &Self, out: &mut Vec<u8>)

Source

fn unpack(buff: &[u8]) -> Result<(usize, Cow<'_, Self>), PackError>

Provided Methods§

Source

fn abs(_item: &Self) -> i64

Source

fn agg(_item: &Self) -> Agg

Source

fn maybe_agg(_item: &Option<Cow<'_, Self>>) -> Agg

Source

fn validate(_val: Option<&Self>, _m: &ScanMeta) -> Result<(), PackError>

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

Source§

fn agg(item: &bool) -> Agg

Source§

fn width(_item: &bool) -> usize

Source§

fn pack(_item: &bool, _out: &mut Vec<u8>)

Source§

fn unpack(_buff: &[u8]) -> Result<(usize, Cow<'_, Self>), PackError>

Source§

impl Packable for i64

Source§

fn abs(item: &Self) -> i64

Source§

fn validate(val: Option<&Self>, _m: &ScanMeta) -> Result<(), PackError>

Source§

fn maybe_agg(item: &Option<Cow<'_, i64>>) -> Agg

Source§

fn width(item: &i64) -> usize

Source§

fn pack(item: &i64, out: &mut Vec<u8>)

Source§

fn unpack(buff: &[u8]) -> Result<(usize, Cow<'_, i64>), PackError>

Source§

impl Packable for str

Source§

fn width(item: &str) -> usize

Source§

fn pack(item: &str, out: &mut Vec<u8>)

Source§

fn unpack(buff: &[u8]) -> Result<(usize, Cow<'_, Self>), PackError>

Source§

impl Packable for u32

Source§

fn validate(val: Option<&Self>, _m: &ScanMeta) -> Result<(), PackError>

Source§

fn agg(item: &u32) -> Agg

Source§

fn width(item: &u32) -> usize

Source§

fn pack(item: &u32, out: &mut Vec<u8>)

Source§

fn unpack(buff: &[u8]) -> Result<(usize, Cow<'static, u32>), PackError>

Source§

impl Packable for u64

Source§

fn maybe_agg(item: &Option<Cow<'_, u64>>) -> Agg

Source§

fn validate(val: Option<&Self>, _m: &ScanMeta) -> Result<(), PackError>

Source§

fn agg(item: &u64) -> Agg

Source§

fn width(item: &u64) -> usize

Source§

fn pack(item: &u64, out: &mut Vec<u8>)

Source§

fn unpack(buff: &[u8]) -> Result<(usize, Cow<'static, u64>), PackError>

Source§

impl Packable for usize

Source§

fn width(item: &Self) -> usize

Source§

fn pack(item: &usize, out: &mut Vec<u8>)

Source§

fn unpack(buff: &[u8]) -> Result<(usize, Cow<'static, Self>), PackError>

Source§

impl Packable for [u8]

Source§

fn width(item: &[u8]) -> usize

Source§

fn pack(item: &[u8], out: &mut Vec<u8>)

Source§

fn unpack(buff: &[u8]) -> Result<(usize, Cow<'_, Self>), PackError>

Implementors§