pub struct RunRule {
pub cur: ByteSet,
pub class: RunClass,
pub min: u8,
pub max: u8,
pub lengths: u64,
pub after: ByteSet,
pub after_end: bool,
pub then: [Option<Then>; 2],
}Expand description
A declarative rule on the run starting at a candidate position, see
Finder::run_rules.
A rule applies when the start byte is in cur; it accepts when the
class run has a length in min..=max (and in lengths when set),
the byte after it is in after (or the input ends there and
after_end is set), and every Then step is met in turn right after
that byte (an IPv4 address starts with 1.2. whatever follows, a MAC
address with aa:bb:cc:). A capped run always satisfies the rest of the
rule, since its true end is unknown.
Fields§
§cur: ByteSet§class: RunClass§min: u8§max: u8§lengths: u64Bit n set: a run of n bytes is accepted; zero means every
length in min..=max. Lengths of 64 and more are governed by
min..=max alone.
after: ByteSet§after_end: bool§then: [Option<Then>; 2]Implementations§
Source§impl RunRule
impl RunRule
Sourcepub fn new(class: RunClass, min: u8, max: u8) -> RunRule
pub fn new(class: RunClass, min: u8, max: u8) -> RunRule
A rule for class runs of min..=max bytes starting at any byte of
the class and followed by any byte, including the end of the input.
Sourcepub fn lengths(self, lengths: u64) -> RunRule
pub fn lengths(self, lengths: u64) -> RunRule
Restricts the rule’s own run to the lengths whose bit is set in
lengths (bit n for n bytes), within min..=max.
Sourcepub fn followed_by(self, bytes: &[u8]) -> RunRule
pub fn followed_by(self, bytes: &[u8]) -> RunRule
Sourcepub fn followed_by_set(self, set: ByteSet) -> RunRule
pub fn followed_by_set(self, set: ByteSet) -> RunRule
Like followed_by with a byte set.
Sourcepub fn or_end(self) -> RunRule
pub fn or_end(self) -> RunRule
Also accepts the end of the input after the last run described so far.
Sourcepub fn then(self, class: RunClass, min: u8, max: u8) -> RunRule
pub fn then(self, class: RunClass, min: u8, max: u8) -> RunRule
Chains a run of class bytes numbering min..=max that must start
right after the byte ending the previous run; it may be followed by
anything until followed_by restricts it. Up
to MAX_THEN steps can be chained. As for the first run, a max
of RUN_CAP means unbounded.