pub struct LengthPrefix<Encodable, Length, Error> { /* private fields */ }
Expand description
Encodes a length prefixed value (TLV).
§Examples
use encode::Encodable;
use encode::combinators::LengthPrefix;
use encode::combinators::FromError;
use core::num::TryFromIntError;
let mut buf = Vec::new();
LengthPrefix::<_, u8, TryFromIntError>::new("hello").encode(&mut buf).unwrap();
assert_eq!(&buf, b"\x05hello", "Using a single byte to indicate the length of the string");
Implementations§
Source§impl<Encodable, Length, Error> LengthPrefix<Encodable, Length, Error>
impl<Encodable, Length, Error> LengthPrefix<Encodable, Length, Error>
Sourcepub fn into_inner(self) -> Encodable
pub fn into_inner(self) -> Encodable
Consumes the combinator and returns the inner encodable.
Trait Implementations§
Source§impl<Encodable, Length, Error> AsRef<Encodable> for LengthPrefix<Encodable, Length, Error>
impl<Encodable, Length, Error> AsRef<Encodable> for LengthPrefix<Encodable, Length, Error>
Source§fn as_ref(&self) -> &Encodable
fn as_ref(&self) -> &Encodable
Converts this type into a shared reference of the (usually inferred) input type.
Source§impl<Encodable, Length, Error> Borrow<Encodable> for LengthPrefix<Encodable, Length, Error>
impl<Encodable, Length, Error> Borrow<Encodable> for LengthPrefix<Encodable, Length, Error>
Source§fn borrow(&self) -> &Encodable
fn borrow(&self) -> &Encodable
Immutably borrows from an owned value. Read more
Source§impl<Encodable, Length, Error> Clone for LengthPrefix<Encodable, Length, Error>where
Encodable: Clone,
impl<Encodable, Length, Error> Clone for LengthPrefix<Encodable, Length, Error>where
Encodable: Clone,
Source§impl<Encodable, Length, Error> Debug for LengthPrefix<Encodable, Length, Error>where
Encodable: Debug,
impl<Encodable, Length, Error> Debug for LengthPrefix<Encodable, Length, Error>where
Encodable: Debug,
Source§impl<Encodable, Length, Error> Default for LengthPrefix<Encodable, Length, Error>where
Encodable: Default,
impl<Encodable, Length, Error> Default for LengthPrefix<Encodable, Length, Error>where
Encodable: Default,
Source§impl<Encodable, Length, Error> Deref for LengthPrefix<Encodable, Length, Error>
impl<Encodable, Length, Error> Deref for LengthPrefix<Encodable, Length, Error>
Source§impl<Encodable, Length, Encoder, Error> Encodable<Encoder> for LengthPrefix<Encodable, Length, Error>where
Encoder: BaseEncoder,
Encodable: Encodable<Encoder> + EncodableSize,
Length: Encodable<Encoder> + TryFrom<usize>,
Error: From<<Length as Encodable<Encoder>>::Error> + From<<Length as TryFrom<usize>>::Error> + From<<Encodable as Encodable<Encoder>>::Error> + From<<Encodable as Encodable<SizeEncoder>>::Error> + From<Encoder::Error>,
impl<Encodable, Length, Encoder, Error> Encodable<Encoder> for LengthPrefix<Encodable, Length, Error>where
Encoder: BaseEncoder,
Encodable: Encodable<Encoder> + EncodableSize,
Length: Encodable<Encoder> + TryFrom<usize>,
Error: From<<Length as Encodable<Encoder>>::Error> + From<<Length as TryFrom<usize>>::Error> + From<<Encodable as Encodable<Encoder>>::Error> + From<<Encodable as Encodable<SizeEncoder>>::Error> + From<Encoder::Error>,
Source§impl<Encodable, Length, Error> From<Encodable> for LengthPrefix<Encodable, Length, Error>
impl<Encodable, Length, Error> From<Encodable> for LengthPrefix<Encodable, Length, Error>
Source§impl<Encodable, Length, Error> Ord for LengthPrefix<Encodable, Length, Error>where
Encodable: Ord,
impl<Encodable, Length, Error> Ord for LengthPrefix<Encodable, Length, Error>where
Encodable: Ord,
Source§impl<Encodable, Length, Error> PartialEq for LengthPrefix<Encodable, Length, Error>where
Encodable: PartialEq,
impl<Encodable, Length, Error> PartialEq for LengthPrefix<Encodable, Length, Error>where
Encodable: PartialEq,
Source§impl<Encodable, Length, Error> PartialOrd for LengthPrefix<Encodable, Length, Error>where
Encodable: PartialOrd,
impl<Encodable, Length, Error> PartialOrd for LengthPrefix<Encodable, Length, Error>where
Encodable: PartialOrd,
impl<Encodable, Length, Error> Copy for LengthPrefix<Encodable, Length, Error>where
Encodable: Copy,
impl<Encodable, Length, Error> Eq for LengthPrefix<Encodable, Length, Error>where
Encodable: Eq,
Auto Trait Implementations§
impl<Encodable, Length, Error> Freeze for LengthPrefix<Encodable, Length, Error>where
Encodable: Freeze,
impl<Encodable, Length, Error> RefUnwindSafe for LengthPrefix<Encodable, Length, Error>
impl<Encodable, Length, Error> Send for LengthPrefix<Encodable, Length, Error>
impl<Encodable, Length, Error> Sync for LengthPrefix<Encodable, Length, Error>
impl<Encodable, Length, Error> Unpin for LengthPrefix<Encodable, Length, Error>
impl<Encodable, Length, Error> UnwindSafe for LengthPrefix<Encodable, Length, Error>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> EncodableSize for Twhere
T: Encodable<SizeEncoder>,
impl<T> EncodableSize for Twhere
T: Encodable<SizeEncoder>,
Source§fn encoded_size(&self) -> Result<usize, <T as Encodable<SizeEncoder>>::Error>
fn encoded_size(&self) -> Result<usize, <T as Encodable<SizeEncoder>>::Error>
Computes the size of the encoded representation of
self
. Read more