pub struct Flags(/* private fields */);
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
§Basic Expression Matching
Basic expression matching option switches.
impl Flags
§Basic Expression Matching
Basic expression matching option switches.
Sourcepub const CASELESS: Self
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.
Sourcepub const DOTALL: Self
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.
Sourcepub const MULTILINE: Self
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.
Sourcepub const ALLOWEMPTY: Self
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.
Sourcepub const UTF8: Self
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.
Sourcepub const UCP: Self
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.
impl Flags
§Complex Options
These flags have a more complex effect on expression parsing or matching.
Sourcepub const SINGLEMATCH: Self
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.
Sourcepub const COMBINATION: Self
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
.
Sourcepub const PREFILTER: Self
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.
Sourcepub const QUIET: Self
pub const QUIET: Self
Ignore match reporting for this expression. Used for the sub-expressions in logical combinations.
Sourcepub const SOM_LEFTMOST: Self
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 BitAndAssign for Flags
impl BitAndAssign for Flags
Source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
&=
operation. Read moreSource§impl BitOrAssign for Flags
impl BitOrAssign for Flags
Source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
|=
operation. Read moreSource§impl Ord for Flags
impl Ord for Flags
Source§impl PartialOrd for Flags
impl PartialOrd for Flags
impl Copy for Flags
impl Eq for Flags
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.