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 { ... }
fn is_empty(&self) -> bool { ... }
}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().
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".