Struct bin_layout::Record
source · [−]pub struct Record<N: FixedLenInt, T> {
pub data: T,
/* private fields */
}Expand description
Record can be used to represent fixed-size integer to represent the length of a record.
It accepts fixed-length unsigned interger type of N (u8, u32, usize, etc..) and a generic type of T (Vec<T>, String etc..)
Example
use bin_layout::{Record, DataType};
let record: Record<u8, &str> = "HelloWorld".into();
assert_eq!(record.len(), 10);
let mut writer = [0; 16].into();
record.serialize(&mut writer);
// One byte for length `u8` and 10 bytes for string. (Total 11 bytes written)
assert_eq!(writer.offset, 11);Fields
data: TImplementations
sourceimpl<N: FixedLenInt, T> Record<N, T>
impl<N: FixedLenInt, T> Record<N, T>
Trait Implementations
sourceimpl<'de, N> DataType<'de> for Record<N, &'de [u8]> where
N: DataType<'de> + FixedLenInt,
usize: TryFrom<N>,
impl<'de, N> DataType<'de> for Record<N, &'de [u8]> where
N: DataType<'de> + FixedLenInt,
usize: TryFrom<N>,
sourcefn serialize(self, view: &mut Cursor<impl AsMut<[u8]>>) -> Result<()>
fn serialize(self, view: &mut Cursor<impl AsMut<[u8]>>) -> Result<()>
Serialize the data to binary format.
sourcefn deserialize(view: &mut Cursor<&'de [u8]>) -> Result<Self>
fn deserialize(view: &mut Cursor<&'de [u8]>) -> Result<Self>
Deserialize the data from binary format.
sourceimpl<'de, N> DataType<'de> for Record<N, String> where
N: DataType<'de> + FixedLenInt,
usize: TryFrom<N>,
impl<'de, N> DataType<'de> for Record<N, String> where
N: DataType<'de> + FixedLenInt,
usize: TryFrom<N>,
sourcefn serialize(self, view: &mut Cursor<impl AsMut<[u8]>>) -> Result<()>
fn serialize(self, view: &mut Cursor<impl AsMut<[u8]>>) -> Result<()>
Serialize the data to binary format.
sourcefn deserialize(view: &mut Cursor<&'de [u8]>) -> Result<Self>
fn deserialize(view: &mut Cursor<&'de [u8]>) -> Result<Self>
Deserialize the data from binary format.
sourceimpl<'de, N> DataType<'de> for Record<N, &'de str> where
N: DataType<'de> + FixedLenInt,
usize: TryFrom<N>,
impl<'de, N> DataType<'de> for Record<N, &'de str> where
N: DataType<'de> + FixedLenInt,
usize: TryFrom<N>,
sourcefn serialize(self, view: &mut Cursor<impl AsMut<[u8]>>) -> Result<()>
fn serialize(self, view: &mut Cursor<impl AsMut<[u8]>>) -> Result<()>
Serialize the data to binary format.
sourcefn deserialize(view: &mut Cursor<&'de [u8]>) -> Result<Self>
fn deserialize(view: &mut Cursor<&'de [u8]>) -> Result<Self>
Deserialize the data from binary format.
sourceimpl<'de, N, T> DataType<'de> for Record<N, Vec<T>> where
T: DataType<'de>,
N: DataType<'de> + FixedLenInt,
usize: TryFrom<N>,
impl<'de, N, T> DataType<'de> for Record<N, Vec<T>> where
T: DataType<'de>,
N: DataType<'de> + FixedLenInt,
usize: TryFrom<N>,
sourcefn serialize(self, view: &mut Cursor<impl AsMut<[u8]>>) -> Result<()>
fn serialize(self, view: &mut Cursor<impl AsMut<[u8]>>) -> Result<()>
Serialize the data to binary format.
sourcefn deserialize(view: &mut Cursor<&'de [u8]>) -> Result<Self>
fn deserialize(view: &mut Cursor<&'de [u8]>) -> Result<Self>
Deserialize the data from binary format.
sourceimpl<N: FixedLenInt, T: Debug> Debug for Record<N, T>
impl<N: FixedLenInt, T: Debug> Debug for Record<N, T>
sourceimpl<N: FixedLenInt, T> Deref for Record<N, T>
impl<N: FixedLenInt, T> Deref for Record<N, T>
sourceimpl<N: FixedLenInt, T> DerefMut for Record<N, T>
impl<N: FixedLenInt, T> DerefMut for Record<N, T>
sourceimpl<N: FixedLenInt, T> From<T> for Record<N, T>
impl<N: FixedLenInt, T> From<T> for Record<N, T>
sourceimpl<N: Ord + FixedLenInt, T: Ord> Ord for Record<N, T>
impl<N: Ord + FixedLenInt, T: Ord> Ord for Record<N, T>
sourceimpl<N: PartialOrd + FixedLenInt, T: PartialOrd> PartialOrd<Record<N, T>> for Record<N, T>
impl<N: PartialOrd + FixedLenInt, T: PartialOrd> PartialOrd<Record<N, T>> for Record<N, T>
sourcefn partial_cmp(&self, other: &Record<N, T>) -> Option<Ordering>
fn partial_cmp(&self, other: &Record<N, T>) -> 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<N: Eq + FixedLenInt, T: Eq> Eq for Record<N, T>
impl<N: FixedLenInt, T> StructuralEq for Record<N, T>
impl<N: FixedLenInt, T> StructuralPartialEq for Record<N, T>
Auto Trait Implementations
impl<N, T> RefUnwindSafe for Record<N, T> where
N: RefUnwindSafe,
T: RefUnwindSafe,
impl<N, T> Send for Record<N, T> where
N: Send,
T: Send,
impl<N, T> Sync for Record<N, T> where
N: Sync,
T: Sync,
impl<N, T> Unpin for Record<N, T> where
N: Unpin,
T: Unpin,
impl<N, T> UnwindSafe for Record<N, T> where
N: UnwindSafe,
T: 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)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more