Function match_pattern

Source
pub fn match_pattern(pattern: &[u8], data: &[u8]) -> (bool, usize)
Expand description

Attempt to match a byte slice against a byte slice.

§Arguments

  • pattern - The byte slice to match against.
  • data - The byte slice to match against.

§Returns

A tuple containing a boolean indicating whether the match succeeded and the number of bytes consumed if the match succeeded.

Examples found in repository?
examples/operators.rs (line 17)
15    fn matcher(&self, data: &[u8]) -> (bool, usize) {
16        match self {
17            OperatorTokens::Equal => match_pattern(b"==", data),
18            OperatorTokens::NotEqual => match_pattern(b"!=", data),
19        }
20    }