use nom::combinator::rest;
use nom::number::streaming::*;
use nom::*;
+use nom::multi::length_data;
use num_traits::FromPrimitive;
#[derive(Debug)]
// DATA TYPES
-named!(#[inline], pub parse_mqtt_string<String>,
- do_parse!(
- length: be_u16
- >> content: take!(length)
- >> (
- String::from_utf8_lossy(&content).to_string()
- )
- ));
+#[inline]
+pub fn parse_mqtt_string(i: &[u8]) -> IResult<&[u8], String> {
+ let (i, content) = length_data(be_u16)(i)?;
+ Ok((i, String::from_utf8_lossy(content).to_string()))
+}
named!(#[inline], pub parse_mqtt_variable_integer<u32>,
do_parse!(
}
// parse properties
let mut props = Vec::<MQTTProperty>::new();
- let (rem, mut newrem) = take!(rem, proplen as usize)?;
+ let (rem, mut newrem) = nom::bytes::complete::take(proplen as usize)(rem)?;
while newrem.len() > 0 {
match parse_property(newrem) {
Ok((rem2, val)) => {