Function mles_utils::read_cid_from_hdr [] [src]

pub fn read_cid_from_hdr(hdrv: &[u8]) -> u32

Read a connection id from header.

Errors

If input vector length is smaller than needed, zero is returned.

Example

use mles_utils::{write_hdr_with_key, write_cid_to_hdr, read_cid_from_hdr, do_hash};

let mut hdr: Vec<u8> = write_hdr_with_key(12, 0x3f3f3); //cid set to zero
let read_cid = read_cid_from_hdr(&hdr);
assert_eq!(0, read_cid);

let hashstr = "Another string".to_string();
let hashable = vec![hashstr];
let key = do_hash(&hashable); 
hdr = write_cid_to_hdr(key, hdr);
let read_cid = read_cid_from_hdr(&hdr);
assert!(read_cid >= 0x1 && read_cid <= 0x7fffffff);