Function jppe::decode

source ·
pub fn decode<'a, T: ByteDecode>(input: &'a [u8]) -> JResult<&'a [u8], T>
Expand description

Decode byte stream

§Examples:

 
use jppe_derive::{ByteDecode};
 
#[derive(Debug, PartialEq, Eq, ByteDecode)]
pub struct SimpleExample {
    pub length: u8,
    #[jppe(length="length")]
    pub data: String,
}
let (input, value) = jppe::decode::<SimpleExample>(b"\x02\x31\x32").unwrap();
assert_eq!(value, SimpleExample { length: 2, data: "12".to_string() });
assert_eq!(input.is_empty(), true);