Struct sequoia_openpgp::regex::Regex [−][src]
pub struct Regex { /* fields omitted */ }
A compiled OpenPGP regular expression for matching UTF-8 encoded strings.
A Regex
contains a regular expression compiled according to the
rules defined in Section 8 of RFC 4880 modulo two differences.
First, the compiler only works on UTF-8 strings (not bytes).
Second, ranges in character classes are between UTF-8 characters,
not just ASCII characters. Further, by default, strings that
don’t pass a sanity check (in particular, include Unicode control
characters) never match. This behavior can be customized using
Regex::disable_sanitizations
.
Regular expressions are used to scope the trust that trust signatures extend.
When working with trust signatures, you’ll usually want to use the
RegexSet
data structure, which already implements the correct
semantics.
See the module-level documentation for more details.
Implementations
impl Regex
[src]
impl Regex
[src]pub fn new(re: &str) -> Result<Self>
[src]
pub fn new(re: &str) -> Result<Self>
[src]Parses and compiles the regular expression.
By default, strings that don’t pass a sanity check (in
particular, include Unicode control characters) never match.
This behavior can be customized using
Regex::disable_sanitizations
.
pub fn from_bytes(re: &[u8]) -> Result<Self>
[src]
pub fn from_bytes(re: &[u8]) -> Result<Self>
[src]Parses and compiles the regular expression.
Returns an error if re
is not a valid UTF-8 string.
By default, strings that don’t pass a sanity check (in
particular, include Unicode control characters) never match.
This behavior can be customized using
Regex::disable_sanitizations
.
pub fn disable_sanitizations(&mut self, disabled: bool)
[src]
pub fn disable_sanitizations(&mut self, disabled: bool)
[src]Controls whether matched strings must pass a sanity check.
If false
(the default), i.e., sanity checks are enabled, and
the string doesn’t pass the sanity check (in particular, it
contains a Unicode control character according to
char::is_control
, including newlines and an embedded NUL
byte), this returns false
.
pub fn is_match(&self, s: &str) -> bool
[src]
pub fn is_match(&self, s: &str) -> bool
[src]Returns whether the regular expression matches the string.
If sanity checks are enabled (the default) and the string
doesn’t pass the sanity check (in particular, it contains a
Unicode control character according to char::is_control
,
including newlines and an embedded NUL
byte), this returns
false
.
pub fn matches_userid(&self, u: &UserID) -> bool
[src]
pub fn matches_userid(&self, u: &UserID) -> bool
[src]Returns whether the regular expression matches the User ID.
If the User ID is not a valid UTF-8 string, this returns
false
.
If sanity checks are enabled (the default) and the string
doesn’t pass the sanity check (in particular, it contains a
Unicode control character according to char::is_control
,
including newlines and an embedded NUL
byte), this returns
false
.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Regex
impl Send for Regex
impl Sync for Regex
impl Unpin for Regex
impl UnwindSafe for Regex
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more