pub trait AsBytes {
// Required methods
fn as_bytes(&self) -> &[u8] ⓘ;
fn len(&self) -> usize;
// Provided methods
fn to_bytes_vec(&self) -> Vec<u8> ⓘ { ... }
fn byte_size(&self) -> usize { ... }
}Expand description
Trait for borrowing data as byte slices.
This trait abstracts the conversion of types that implement Pod (or collections thereof)
into their raw byte representation as a slice (&[u8]).
Required Methods§
Provided Methods§
Sourcefn to_bytes_vec(&self) -> Vec<u8> ⓘ
fn to_bytes_vec(&self) -> Vec<u8> ⓘ
Returns an owned vector containing a copy of the bytes of the data.
The default implementation clones the bytes from as_bytes().
Implementations on Foreign Types§
Source§impl<T> AsBytes for (T,)where
T: Pod,
Implementation for single POD types wrapped in a tuple (T,).
impl<T> AsBytes for (T,)where
T: Pod,
Implementation for single POD types wrapped in a tuple (T,).
Source§impl<T, const N: usize> AsBytes for [T; N]where
T: Pod,
Implementation for [T; N] where T is POD.
impl<T, const N: usize> AsBytes for [T; N]where
T: Pod,
Implementation for [T; N] where T is POD.