Function serde_rosmsg::from_slice [] [src]

pub fn from_slice<'de, T>(bytes: &[u8]) -> Result<T> where
    T: Deserialize<'de>, 

Deserialize an instance of type T from bytes of ROSMSG data.

This conversion can fail if the passed stream of bytes does not match the structure expected by T. It can also fail if the structure contains unsupported elements.

Examples

let value: String = from_slice(&[
    17, 0, 0, 0,
    13, 0, 0, 0,
    72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33]).unwrap();
assert_eq!(value, "Hello, World!");

let value: (u16, u16) = from_slice(&[4, 0, 0, 0, 2, 4, 8, 16]).unwrap();
assert_eq!(value, (1026, 4104));