Skip to main content

parse_message

Function parse_message 

Source
pub fn parse_message(input: &str) -> IResult<&str, String>
Expand description

Parse the message part of a magic rule

The message is everything after the value until the end of the line. It may contain format specifiers and can be empty.

§Examples

use libmagic_rs::parser::grammar::parse_message;

assert_eq!(parse_message("ELF executable"), Ok(("", "ELF executable".to_string())));
assert_eq!(parse_message(""), Ok(("", "".to_string())));
assert_eq!(parse_message("  \tPDF document  "), Ok(("", "PDF document".to_string())));

Parse the message/description part of a magic rule

§Errors

Returns a nom parsing error if the input cannot be parsed as a message