Struct Wildcard
pub struct Wildcard<'a, S = u8>where
S: WildcardSymbol,{ /* private fields */ }Expand description
A wildcard. You can use this to check for match against input sequences:
let wildcard = Wildcard::new("*foo?*bar".as_bytes()).expect("invalid wildcard");
assert!(wildcard.is_match("fooofooobar".as_bytes()));Implementations§
§impl<'a, S> Wildcard<'a, S>where
S: WildcardSymbol,
impl<'a, S> Wildcard<'a, S>where
S: WildcardSymbol,
pub fn new(pattern: &'a [S]) -> Result<Wildcard<'a, S>, WildcardError>
pub fn new(pattern: &'a [S]) -> Result<Wildcard<'a, S>, WildcardError>
Creates a wildcard.
pub fn from_owned(
pattern: Vec<S>,
) -> Result<Wildcard<'static, S>, WildcardError>
pub fn from_owned( pattern: Vec<S>, ) -> Result<Wildcard<'static, S>, WildcardError>
Creates a wildcard.
pub fn captures<'b>(&self, input: &'b [S]) -> Option<Vec<&'b [S]>>
pub fn captures<'b>(&self, input: &'b [S]) -> Option<Vec<&'b [S]>>
Captures all input substrings that matched the wildcard’s metasymbols. This returns
None if there’s no match.
let wildcard = Wildcard::new("* is part of *".as_bytes()).unwrap();
let captures: Vec<&[u8]> = wildcard.captures("Lisboa is part of Portugal".as_bytes()).unwrap();
assert_eq!(captures, ["Lisboa".as_bytes(), "Portugal".as_bytes()]);The captures are done in a lazy way: earlier captures will be as small as possible.
pub fn metasymbol_count(&self) -> usize
pub fn metasymbol_count(&self) -> usize
Number of metasymbols in the wildcard. The number of captures returned by
Wildcard::captures(), if there is match, will be the same as the number of metasymbols.
pub fn parsed(&self) -> impl Iterator<Item = WildcardToken<S>>
pub fn parsed(&self) -> impl Iterator<Item = WildcardToken<S>>
Parse the wildcard into tokens.
Trait Implementations§
§impl<'a, S> Clone for Wildcard<'a, S>where
S: Clone + WildcardSymbol,
impl<'a, S> Clone for Wildcard<'a, S>where
S: Clone + WildcardSymbol,
§impl<'a, S> Debug for Wildcard<'a, S>where
S: WildcardSymbol + Display,
impl<'a, S> Debug for Wildcard<'a, S>where
S: WildcardSymbol + Display,
§impl From<Wildcard<'static>> for UriMatcher
impl From<Wildcard<'static>> for UriMatcher
§fn from(wc: Wildcard<'static>) -> UriMatcher
fn from(wc: Wildcard<'static>) -> UriMatcher
Converts to this type from the input type.
Auto Trait Implementations§
impl<'a, S> Freeze for Wildcard<'a, S>where
S: Freeze,
impl<'a, S> RefUnwindSafe for Wildcard<'a, S>where
S: RefUnwindSafe,
impl<'a, S> Send for Wildcard<'a, S>
impl<'a, S> Sync for Wildcard<'a, S>where
S: Sync,
impl<'a, S> Unpin for Wildcard<'a, S>where
S: Unpin,
impl<'a, S> UnwindSafe for Wildcard<'a, S>where
S: UnwindSafe + RefUnwindSafe,
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
Converts
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> ⓘ
Converts
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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Create a new
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more