Function tr1pd::wire::len_to_u16_vec [] [src]

pub fn len_to_u16_vec(i: usize) -> Result<[u8; 2]>

Convert the length to a byte array (big endian).

use tr1pd::wire::len_to_u16_vec;

// regular block
len_to_u16_vec(25).ok().unwrap();
// maximum block size
len_to_u16_vec(65535).ok().unwrap();
// too large
len_to_u16_vec(65536).err().unwrap();
// way too large
len_to_u16_vec(52_428_800).err().unwrap();