pub struct Record<Len: LenType, T> {
pub data: T,
/* private fields */
}
Expand description
Record can be used to encode collections where the size of the length is known.
For example, Record<u8, String>
here the maximum allowed payload length is 255 (u8::MAX
)
§Example
use bin_layout::*;
let record: Record<u8, String> = "very long string!".repeat(15).into();
let bytes = record.encode();
assert_eq!(record.len(), 255);
assert_eq!(bytes.len(), 256);
Fields§
§data: T
Implementations§
Trait Implementations§
Source§impl<'de, Len: LenType, K: Decoder<'de> + Ord, V: Decoder<'de>> Decoder<'de> for Record<Len, BTreeMap<K, V>>
impl<'de, Len: LenType, K: Decoder<'de> + Ord, V: Decoder<'de>> Decoder<'de> for Record<Len, BTreeMap<K, V>>
Source§impl<'de, Len: LenType, K: Decoder<'de> + Eq + Hash, V: Decoder<'de>, S: BuildHasher + Default> Decoder<'de> for Record<Len, HashMap<K, V, S>>
impl<'de, Len: LenType, K: Decoder<'de> + Eq + Hash, V: Decoder<'de>, S: BuildHasher + Default> Decoder<'de> for Record<Len, HashMap<K, V, S>>
Source§impl<'de, Len: LenType, T: Decoder<'de> + Eq + Hash, S: BuildHasher + Default> Decoder<'de> for Record<Len, HashSet<T, S>>
impl<'de, Len: LenType, T: Decoder<'de> + Eq + Hash, S: BuildHasher + Default> Decoder<'de> for Record<Len, HashSet<T, S>>
Source§impl<Len: LenType, T, V: FromIterator<T>> FromIterator<T> for Record<Len, V>
impl<Len: LenType, T, V: FromIterator<T>> FromIterator<T> for Record<Len, V>
Source§fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
Creates a value from an iterator. Read more
Source§impl<Len: Ord + LenType, T: Ord> Ord for Record<Len, T>
impl<Len: Ord + LenType, T: Ord> Ord for Record<Len, T>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<Len: PartialOrd + LenType, T: PartialOrd> PartialOrd for Record<Len, T>
impl<Len: PartialOrd + LenType, T: PartialOrd> PartialOrd for Record<Len, T>
impl<Len: Eq + LenType, T: Eq> Eq for Record<Len, T>
impl<Len: LenType, T> StructuralPartialEq for Record<Len, T>
Auto Trait Implementations§
impl<Len, T> Freeze for Record<Len, T>where
T: Freeze,
impl<Len, T> RefUnwindSafe for Record<Len, T>where
T: RefUnwindSafe,
Len: RefUnwindSafe,
impl<Len, T> Send for Record<Len, T>
impl<Len, T> Sync for Record<Len, T>
impl<Len, T> Unpin for Record<Len, T>
impl<Len, T> UnwindSafe for Record<Len, T>where
T: UnwindSafe,
Len: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more