Function hdlc::encode [−][src]
pub fn encode(data: Vec<u8>, s_chars: SpecialChars) -> Result<Vec<u8>>
Produces escaped and FEND surrounded message.
Inputs: Vec
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![0x01, 0x50, 0x00, 0x00, 0x00, 0x05, 0x80, 0x09]; let op_vec = hdlc::encode(input.to_vec(), chars);