pub struct TreCompiledPattern { /* private fields */ }Expand description
Owning handle to a TRE-compiled pattern.
Construct via TreCompiledPattern::compile. The native
resources are released by Drop (delegated to the
tre-sys::OwnedRegex field).
Implementations§
Source§impl TreCompiledPattern
impl TreCompiledPattern
Sourcepub fn compile(pattern: &[u8], opts: TreMatchOpts) -> Result<Self, TreError>
pub fn compile(pattern: &[u8], opts: TreMatchOpts) -> Result<Self, TreError>
Compile a regex pattern.
The pattern is read as bytes. The vendored TRE build disables multibyte handling, so byte n in the pattern is matched against byte n in the haystack regardless of the host locale.
Sourcepub fn is_match(&self, text: &[u8]) -> bool
pub fn is_match(&self, text: &[u8]) -> bool
Return true if text contains an approximate match
for the pattern within the configured error budget.
Sourcepub fn matches(&self, text: &[u8]) -> Option<TreMatch>
pub fn matches(&self, text: &[u8]) -> Option<TreMatch>
Return the first approximate match in text, if any.
On a non-REG_OK/REG_NOMATCH return code from TRE
the function returns None and asserts in debug builds.
In release the failure is treated as a no-match because
the only documented non-fatal failure for the
approximate matcher is back-references in the pattern,
which dyntext does not generate.
Sourcepub fn opts(&self) -> TreMatchOpts
pub fn opts(&self) -> TreMatchOpts
Borrow the cached options. Useful for tests and for callers that want to re-use the same configuration.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TreCompiledPattern
impl RefUnwindSafe for TreCompiledPattern
impl !Send for TreCompiledPattern
impl !Sync for TreCompiledPattern
impl Unpin for TreCompiledPattern
impl UnsafeUnpin for TreCompiledPattern
impl UnwindSafe for TreCompiledPattern
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more