Function hdlc::decode[][src]

pub fn decode(input: Vec<u8>, s_chars: SpecialChars) -> Result<Vec<u8>>

Produces unescaped message without FEND characters.

Inputs: Vec: a vector of the bytes you want to decode Inputs: SpecialChars: the special characters you want to swap

Returns: Decoded output message as Result<Vec<u8>>

Safety: Checks special characters for duplicates

Error: "Duplicate special character". If any of the SpecialChars are duplicate, throw an error

Todo: Catch more errors, like an incomplete packet

Example

extern crate hdlc;
let chars = hdlc::SpecialChars::default();
let input: Vec<u8> = vec![ 0x7E, 0x01, 0x50, 0x00, 0x00, 0x00, 0x05, 0x80, 0x09, 0x7E];
let op_vec = hdlc::decode(input.to_vec(), chars);