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 save(item: &Self) -> Vec<u8> ⓘ { ... }
fn maybe_agg(_item: &Option<Cow<'_, Self>>) -> Agg { ... }
fn validate<F>(val: Option<&Self>, validate: &F) -> Result<(), PackError>
where F: Fn(Option<&Self>) -> Option<String> { ... }
}Expand description
Types that can be encoded into and decoded from the hexane columnar format.
Implemented for the primitive types used by the built-in cursors: u64, i64, u32,
usize, bool, str, and [u8].
To use a custom type with RleCursor, implement Packable for it.
pack/unpack: byte-level serialization (typically LEB128 for integers).width: the number of bytespackwill write, used for capacity estimation.agg: the per-itemAggaggregate (defaults toAgg::default()= no accumulation).abs: the “absolute” value for delta encoding (i64only).
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 save(item: &Self) -> Vec<u8> ⓘ
fn maybe_agg(_item: &Option<Cow<'_, Self>>) -> Agg
fn validate<F>(val: Option<&Self>, validate: &F) -> 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.