pub fn parse_rule_offset(input: &str) -> IResult<&str, (u32, OffsetSpec)>Expand description
Parse the indentation level and offset for magic rules
Handles both absolute offsets and hierarchical child rules with > prefix.
Child rules can be nested multiple levels deep with multiple > characters.
§Examples
use libmagic_rs::parser::grammar::parse_rule_offset;
use libmagic_rs::parser::ast::OffsetSpec;
// Absolute offset
assert_eq!(parse_rule_offset("0"), Ok(("", (0, OffsetSpec::Absolute(0)))));
assert_eq!(parse_rule_offset("16"), Ok(("", (0, OffsetSpec::Absolute(16)))));
// Child rule (level 1)
assert_eq!(parse_rule_offset(">4"), Ok(("", (1, OffsetSpec::Absolute(4)))));
// Nested child rule (level 2)
assert_eq!(parse_rule_offset(">>8"), Ok(("", (2, OffsetSpec::Absolute(8)))));Parse rule offset with hierarchy level (> prefixes) and offset specification
§Errors
Returns a nom parsing error if the input doesn’t match the expected offset format