Struct Flags

Source
pub struct Flags(/* private fields */);
Available on crate feature compiler only.
Expand description

Flags which modify the behaviour of individual expressions.

These flags are provided to every compiler method, although each method may only accept a subset of all flags. Multiple flags may be used by ORing them together.

Note that flags may always be overridden by switches in the pattern string such as (?i) for case-insensitive matching.

Implementations§

Source§

impl Flags

Source

pub const NONE: Self

Disable all flags.

Source§

impl Flags

§Basic Expression Matching

Basic expression matching option switches.

Source

pub const CASELESS: Self

Matching will be performed case-insensitively.

This flag sets the expression to be matched case-insensitively by default. The expression may still use PCRE tokens (notably (?i) and (?-i)) to switch case-insensitive matching on and off.

Source

pub const DOTALL: Self

Matching a . will not exclude newlines.

This flag sets any instances of the . token to match newline characters as well as all other characters. The PCRE specification states that the . token does not match newline characters by default, so without this flag the . token will not cross line boundaries.

Source

pub const MULTILINE: Self

^ and $ anchors match any newlines in data.

This flag instructs the expression to make the ^ and $ tokens match newline characters as well as the start and end of the stream. If this flag is not specified, the ^ token will only ever match at the start of a stream, and the $ token will only ever match at the end of a stream within the guidelines of the PCRE specification.

Source

pub const ALLOWEMPTY: Self

Allow expressions which can match against an empty string, such as .*.

This flag instructs the compiler to allow expressions that can match against empty buffers, such as .?, .*, (a|). Since Vectorscan can return every possible match for an expression, such expressions generally execute very slowly; the default behaviour is to return an error when an attempt to compile one is made. Using this flag will force the compiler to allow such an expression.

Also consider ExprExt::from_min_length() to bound the minimum match length instead of forcing vectorscan to accept possibly slow match behavior.

Source

pub const UTF8: Self

Enable UTF-8 mode for this expression.

This flag instructs Vectorscan to treat the pattern as a sequence of UTF-8 characters. The results of scanning invalid UTF-8 sequences with a Vectorscan library that has been compiled with one or more patterns using this flag are undefined.

Source

pub const UCP: Self

Enable Unicode property support for this expression.

This flag instructs Vectorscan to use Unicode properties, rather than the default ASCII interpretations, for character mnemonics like \w and \s as well as the POSIX character classes. It is only meaningful in conjunction with Self::UTF8.

Source§

impl Flags

§Complex Options

These flags have a more complex effect on expression parsing or matching.

Source

pub const SINGLEMATCH: Self

Only one match will be generated by patterns with this match id per stream.

This flag sets the expression’s match ID to match at most once. In streaming mode, this means that the expression will return only a single match over the lifetime of the stream, rather than reporting every match as per standard Vectorscan semantics. In block mode or vectored mode, only the first match for each invocation of scan_sync() or scan_sync_vectored() will be returned.

If multiple expressions in the database share the same match ID, then they either must all specify SINGLEMATCH or none of them specify SINGLEMATCH. If a group of expressions sharing a match ID specify the flag, then at most one match with the match ID will be generated per stream.

Note: The use of this flag in combination with Self::SOM_LEFTMOST is not currently supported.

Source

pub const COMBINATION: Self

Parse the expression in logical combination syntax.

This flag instructs Vectorscan to parse this expression as logical combination syntax. Logical constraints consist of operands, operators and parentheses. The operands are expression indices, and operators can be:

  • ! (NOT),
  • & (AND), or
  • | (OR).

For example:

 (101&102&103)|(104&!105)
 ((301|302)&303)&(304|305)

When an expression has this flag set, it ignores all other flags except Self::SINGLEMATCH and Self::QUIET.

Source

pub const PREFILTER: Self

Compile pattern in prefiltering mode.

This flag instructs Vectorscan to compile an “approximate” version of this pattern for use in a prefiltering application, even if Vectorscan does not support the pattern in normal operation.

The set of matches returned when this flag is used is guaranteed to be a superset of the matches specified by the non-prefiltering expression.

If the pattern contains pattern constructs not supported by Vectorscan (such as zero-width assertions, back-references or conditional references) these constructs will be replaced internally with broader constructs that may match more often.

Furthermore, in prefiltering mode Vectorscan may simplify a pattern that would otherwise return a “Pattern too large” error at compile time, or for performance reasons (subject to the matching guarantee above).

It is generally expected that the application will subsequently confirm prefilter matches with another regular expression matcher that can provide exact matches for the pattern.

Note: The use of this flag in combination with Self::SOM_LEFTMOST is not currently supported.

Source

pub const QUIET: Self

Ignore match reporting for this expression. Used for the sub-expressions in logical combinations.

Source

pub const SOM_LEFTMOST: Self

Report the leftmost start of match offset when a match is found.

This flag instructs Vectorscan to report the leftmost possible start of match offset when a match is reported for this expression. (By default, no start of match is returned.)

For all the 3 modes Mode::SOM_HORIZON_LARGE, Mode::SOM_HORIZON_MEDIUM, and Mode::SOM_HORIZON_SMALL, enabling this behaviour may reduce performance. And particularly, it may increase stream state requirements in streaming mode.

See the Start of Match reference for more details.

Trait Implementations§

Source§

impl BitAnd for Flags

Source§

type Output = Flags

The resulting type after applying the & operator.
Source§

fn bitand(self, other: Self) -> Self

Performs the & operation. Read more
Source§

impl BitAndAssign for Flags

Source§

fn bitand_assign(&mut self, rhs: Self)

Performs the &= operation. Read more
Source§

impl BitOr for Flags

Source§

type Output = Flags

The resulting type after applying the | operator.
Source§

fn bitor(self, other: Self) -> Self

Performs the | operation. Read more
Source§

impl BitOrAssign for Flags

Source§

fn bitor_assign(&mut self, rhs: Self)

Performs the |= operation. Read more
Source§

impl BitSet for Flags

Source§

fn nonzero(&self) -> bool

Whether the underlying integer storing this bitset is not equal to 0. Read more
Source§

fn contains(&self, other: &Self) -> bool

Whether the other flag was provided to the current bitset.
Source§

impl Clone for Flags

Source§

fn clone(&self) -> Flags

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Flags

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Flags

Source§

fn default() -> Flags

Returns the “default value” for a type. Read more
Source§

impl Hash for Flags

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Not for Flags

Source§

type Output = Flags

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl Ord for Flags

Source§

fn cmp(&self, other: &Flags) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Flags

Source§

fn eq(&self, other: &Flags) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Flags

Source§

fn partial_cmp(&self, other: &Flags) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for Flags

Source§

impl Eq for Flags

Source§

impl StructuralPartialEq for Flags

Auto Trait Implementations§

§

impl Freeze for Flags

§

impl RefUnwindSafe for Flags

§

impl Send for Flags

§

impl Sync for Flags

§

impl Unpin for Flags

§

impl UnwindSafe for Flags

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.