pub struct LengthPrefixedVector<'a, T: Clone> { /* private fields */ }Expand description
A wrapper around a Vec<T> for any T with ProtocolEncoding that can be safely
encoded and decoded using a CompactSize length prefix
Max allocation size is protected to MAX_VEC_SIZE.
Implementations§
Source§impl<'a, T: Clone> LengthPrefixedVector<'a, T>
impl<'a, T: Clone> LengthPrefixedVector<'a, T>
Sourcepub fn new(buf: &'a [T]) -> Self
pub fn new(buf: &'a [T]) -> Self
Create a new LengthPrefixedVector wrapping the slice
Sourcepub fn into_inner(self) -> Vec<T>
pub fn into_inner(self) -> Vec<T>
Unwrap into inner vector
Trait Implementations§
Source§impl<'a, T: Clone + Clone> Clone for LengthPrefixedVector<'a, T>
impl<'a, T: Clone + Clone> Clone for LengthPrefixedVector<'a, T>
Source§fn clone(&self) -> LengthPrefixedVector<'a, T>
fn clone(&self) -> LengthPrefixedVector<'a, T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<'a, T: ProtocolEncoding + Clone> ProtocolEncoding for LengthPrefixedVector<'a, T>
impl<'a, T: ProtocolEncoding + Clone> ProtocolEncoding for LengthPrefixedVector<'a, T>
Source§fn encode<W: Write + ?Sized>(&self, w: &mut W) -> Result<(), Error>
fn encode<W: Write + ?Sized>(&self, w: &mut W) -> Result<(), Error>
Encode the object into the writer.
Source§fn decode<R: Read + ?Sized>(r: &mut R) -> Result<Self, ProtocolDecodingError>
fn decode<R: Read + ?Sized>(r: &mut R) -> Result<Self, ProtocolDecodingError>
Decode the object from the writer.
Source§fn deserialize(byte_slice: &[u8]) -> Result<Self, ProtocolDecodingError>
fn deserialize(byte_slice: &[u8]) -> Result<Self, ProtocolDecodingError>
Deserialize object from the given byte slice.
Source§fn serialize_hex(&self) -> String
fn serialize_hex(&self) -> String
Serialize the object to a lowercase hex string.
Source§fn deserialize_hex(hex_str: &str) -> Result<Self, ProtocolDecodingError>
fn deserialize_hex(hex_str: &str) -> Result<Self, ProtocolDecodingError>
Deserialize object from hex slice.
Auto Trait Implementations§
impl<'a, T> Freeze for LengthPrefixedVector<'a, T>
impl<'a, T> RefUnwindSafe for LengthPrefixedVector<'a, T>where
T: RefUnwindSafe,
impl<'a, T> Send for LengthPrefixedVector<'a, T>
impl<'a, T> Sync for LengthPrefixedVector<'a, T>where
T: Sync,
impl<'a, T> Unpin for LengthPrefixedVector<'a, T>where
T: Unpin,
impl<'a, T> UnsafeUnpin for LengthPrefixedVector<'a, T>
impl<'a, T> UnwindSafe for LengthPrefixedVector<'a, T>where
T: RefUnwindSafe + 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