Skip to main content

parse_cn_msg

Function parse_cn_msg 

Source
pub fn parse_cn_msg(buf: &[u8]) -> Result<ProcEvent>
Expand description

Parse a cn_msg payload (starting from cb_id) into a ProcEvent.

§Example

use proc_connector::{parse_cn_msg, Error};

// Too short → Truncated
let buf = [0u8; 10];
assert!(matches!(parse_cn_msg(&buf), Err(Error::Truncated)));

// Wrong connector index → UnexpectedConnector
let mut buf = [0u8; 20];
buf[0..4].copy_from_slice(&999u32.to_ne_bytes()); // wrong idx
assert!(matches!(parse_cn_msg(&buf), Err(Error::UnexpectedConnector)));