Struct bin_layout::Record
source · [−]pub struct Record<Len, Type> {
pub data: Type,
/* private fields */
}Expand description
This utility struct use for serialize or deserialize variable length records.
By default, String or Vec<T> are encoded with their length value first,
Size of size is u32
But this utility struct allow you to encode different length size, for example: u8, u16, usize etc…
Example
use bin_layout::{DataType, Record};
let record: Record<u8, String> = String::from("HelloWorld").into();
assert_eq!(record.len(), 10);
let mut buf = [0; 16].into();
DataType::serialize(record, &mut buf);
// One byte for length, 10 bytes for string
assert_eq!(buf.offset, 11); // 11 bytes written to bufferFields
data: TypeTrait Implementations
sourceimpl<E> DataType for Record<E, String> where
E: Endian + TryFrom<usize>,
E::Error: Debug,
usize: TryFrom<E>,
impl<E> DataType for Record<E, String> where
E: Endian + TryFrom<usize>,
E::Error: Debug,
usize: TryFrom<E>,
sourceimpl<E, D> DataType for Record<E, Vec<D>> where
D: DataType,
E: Endian + TryFrom<usize>,
E::Error: Debug,
usize: TryFrom<E>,
impl<E, D> DataType for Record<E, Vec<D>> where
D: DataType,
E: Endian + TryFrom<usize>,
E::Error: Debug,
usize: TryFrom<E>,
sourceimpl<Len: Ord, Type: Ord> Ord for Record<Len, Type>
impl<Len: Ord, Type: Ord> Ord for Record<Len, Type>
sourceimpl<Len: PartialOrd, Type: PartialOrd> PartialOrd<Record<Len, Type>> for Record<Len, Type>
impl<Len: PartialOrd, Type: PartialOrd> PartialOrd<Record<Len, Type>> for Record<Len, Type>
sourcefn partial_cmp(&self, other: &Record<Len, Type>) -> Option<Ordering>
fn partial_cmp(&self, other: &Record<Len, Type>) -> Option<Ordering>
This method returns an ordering between self and other values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
impl<Len: Eq, Type: Eq> Eq for Record<Len, Type>
impl<Len, Type> StructuralEq for Record<Len, Type>
impl<Len, Type> StructuralPartialEq for Record<Len, Type>
Auto Trait Implementations
impl<Len, Type> RefUnwindSafe for Record<Len, Type> where
Len: RefUnwindSafe,
Type: RefUnwindSafe,
impl<Len, Type> Send for Record<Len, Type> where
Len: Send,
Type: Send,
impl<Len, Type> Sync for Record<Len, Type> where
Len: Sync,
Type: Sync,
impl<Len, Type> Unpin for Record<Len, Type> where
Len: Unpin,
Type: Unpin,
impl<Len, Type> UnwindSafe for Record<Len, Type> where
Len: UnwindSafe,
Type: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more