Function jppe::encode_borrow

source ·
pub fn encode_borrow<'a, T: BorrowByteEncode>(t: T) -> Vec<u8>
Expand description

Encode byte stream

§Examples:

 
use jppe_derive::{BorrowByteEncode};
 
#[derive(Debug, PartialEq, Eq, BorrowByteEncode)]
pub struct SimpleExample<'a> {
    pub length: u8,
    #[jppe(length="length")]
    pub data: &'a [u8],
}
let value = SimpleExample { length: 2, data: b"12" };
assert_eq!(jppe::encode_borrow(value), b"\x02\x31\x32");