Trait kwap_msg::TryIntoBytes [−][src]
pub trait TryIntoBytes {
type Error;
fn try_into_bytes<C: Array<Item = u8>>(self) -> Result<C, Self::Error>;
}
Expand description
Trait allowing fallible conversion into bytes
Associated Types
Required methods
Try to convert into a collection of bytes
use kwap_msg::TryIntoBytes;
// This one has static params that allocates space on the static
// and uses `tinyvec::ArrayVec` as the byte buffer backing structure
let arrayvec_message = kwap_msg::ArrayVecMessage::<0, 0, 0> {
// ...
};
let bytes: tinyvec::ArrayVec<[u8; 1024]> = arrayvec_message.try_into_bytes().unwrap();
// This one uses Vec
let vec_message = kwap_msg::VecMessage {
// ...
};
let bytes: Vec<u8> = vec_message.try_into_bytes().unwrap();