Function rscache::parse::rs_string[][src]

pub fn rs_string<'a, E: ParseError<&'a [u8]>>(
    buffer: &'a [u8]
) -> IResult<&'a [u8], String, E>
Expand description

Reads a 0-terminated string from the given buffer. Uses String::from_utf8_lossy() for the conversion.

Errors

Parser can reach EOF early if not enough bytes are supplied or no 0-termination character is present.

Example

use rscache::parse::rs_string;

let buffer = &[82, 117, 110, 105, 116, 101, 32, 98, 97, 114, 0, 52, 14, 85, 65, 4, 56];

let (buffer, string) = rs_string(buffer)?;

assert_eq!(&string, "Runite bar");
assert_eq!(buffer, &[52, 14, 85, 65, 4, 56]);