pub trait TryIntoBytes {
;

    // Required method
;
}
Expand description

Trait allowing fallible conversion into bytes

Required Associated Types§

Required Methods§

source

Try to convert into a collection of bytes

use tinyvec::ArrayVec;
use toad_msg::{Message, OptNumber, OptValue, TryIntoBytes};

type OptionValue = OptValue<ArrayVec<[u8; 128]>>;
type OptionMapEntry = (OptNumber, ArrayVec<[OptionValue; 4]>);
type OptionMap = ArrayVec<[OptionMapEntry; 16]>;
type Payload = ArrayVec<[u8; 1024]>;
let arrayvec_message = Message::<Payload, OptionMap> {
  // ...
};

let bytes: tinyvec::ArrayVec<[u8; 1024]> = arrayvec_message.try_into_bytes().unwrap();

// This one uses Vec
let vec_message = toad_msg::alloc::Message {
  // ...
};

let bytes: Vec<u8> = vec_message.try_into_bytes().unwrap();

Implementors§

source§

impl<PayloadBytes: Array<Item = u8>, Options: OptionMap> TryIntoBytes for Message<PayloadBytes, Options>

§

type Error = MessageToBytesError