pub trait IntoBytes {
// Required method
fn into_bytes(self) -> Vec<u8> ⓘ;
}Expand description
Trait for consuming data into an owned byte vector.
This trait is for types that can be meaningfully converted into a Vec< u8 >
by consuming the original value.
Required Methods§
Sourcefn into_bytes(self) -> Vec<u8> ⓘ
fn into_bytes(self) -> Vec<u8> ⓘ
Consumes the value and returns its byte representation as an owned Vec< u8 >.
Implementations on Foreign Types§
Source§impl IntoBytes for CString
Implementation for CString.
Returns the byte slice without the trailing NUL byte.
impl IntoBytes for CString
Implementation for CString. Returns the byte slice without the trailing NUL byte.
Source§impl<T> IntoBytes for &[T]where
T: Pod,
Implementation for &[T] where T is Pod.
This handles slices of POD types specifically.
impl<T> IntoBytes for &[T]where
T: Pod,
Implementation for &[T] where T is Pod. This handles slices of POD types specifically.
Source§impl<T> IntoBytes for (T,)where
T: Pod,
Implementation for single POD types wrapped in a tuple (T,).
This mirrors the approach used in AsBytes for consistency with single items.
Covers primitive types (u8, i32, f64, bool, etc.) and other POD structs when wrapped.
impl<T> IntoBytes for (T,)where
T: Pod,
Implementation for single POD types wrapped in a tuple (T,).
This mirrors the approach used in AsBytes for consistency with single items.
Covers primitive types (u8, i32, f64, bool, etc.) and other POD structs when wrapped.
Source§impl<T, const N: usize> IntoBytes for [T; N]where
T: Pod,
Implementation for owned arrays of POD types.
impl<T, const N: usize> IntoBytes for [T; N]where
T: Pod,
Implementation for owned arrays of POD types.