Struct DomainPattern
pub struct DomainPattern(/* private fields */);net only.Expand description
A compiled pattern for matching validated domain names.
The representation is intentionally private. Construct patterns explicitly
with exact, sub, or
try_glob, or parse conventional pattern syntax through
try_new.
use rama_net::address::{Domain, DomainPattern};
let pattern = DomainPattern::sub(Domain::from_static("example.com"));
assert!(pattern.matches(Domain::from_static("api.example.com").view()));
assert!(!pattern.matches(Domain::from_static("example.net").view()));Implementations§
§impl DomainPattern
impl DomainPattern
pub const fn exact(domain: Domain) -> DomainPattern
pub const fn exact(domain: Domain) -> DomainPattern
pub fn sub(domain: Domain) -> DomainPattern
pub fn sub(domain: Domain) -> DomainPattern
Match a domain and all of its descendants.
This constructor performs no parsing. If domain is already in Rama’s
*.example.com wildcard form or its presentation has a leading dot,
the stored subtree apex is normalized to example.com.
pub fn try_glob(
pattern: impl Into<Cow<'static, str>>,
) -> Result<DomainPattern, Box<dyn Error + Sync + Send>>
pub fn try_glob( pattern: impl Into<Cow<'static, str>>, ) -> Result<DomainPattern, Box<dyn Error + Sync + Send>>
Compile a case-insensitive domain glob.
* matches any sequence of bytes, including dots. Exact and subtree
matching should use Self::exact and Self::sub instead. Domain
globs are restricted to ASCII because wildcard-aware IDNA conversion is
ambiguous; exact and subtree patterns retain the normal Domain IDNA
behavior. A static string is borrowed by the compiled wildcard; an
owned String transfers its allocation.
pub fn try_new(
pattern: impl TryIntoDomainPattern,
) -> Result<DomainPattern, Box<dyn Error + Sync + Send>>
pub fn try_new( pattern: impl TryIntoDomainPattern, ) -> Result<DomainPattern, Box<dyn Error + Sync + Send>>
Parse a domain pattern.
Plain domains are exact, .example.com and *.example.com are subtree
patterns, and other values containing * are globs.
Trait Implementations§
§impl Clone for DomainPattern
impl Clone for DomainPattern
§fn clone(&self) -> DomainPattern
fn clone(&self) -> DomainPattern
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for DomainPattern
impl Debug for DomainPattern
§impl From<DomainPattern> for HostPattern
Preserve a domain pattern’s exact, subtree, or glob semantics while
widening its candidate type to Host.
impl From<DomainPattern> for HostPattern
Preserve a domain pattern’s exact, subtree, or glob semantics while
widening its candidate type to Host.
§fn from(pattern: DomainPattern) -> HostPattern
fn from(pattern: DomainPattern) -> HostPattern
§impl FromStr for DomainPattern
impl FromStr for DomainPattern
§impl TryFrom<Box<str>> for DomainPattern
impl TryFrom<Box<str>> for DomainPattern
§impl TryFrom<HostPattern> for DomainPattern
impl TryFrom<HostPattern> for DomainPattern
§fn try_from(
pattern: HostPattern,
) -> Result<DomainPattern, <DomainPattern as TryFrom<HostPattern>>::Error>
fn try_from( pattern: HostPattern, ) -> Result<DomainPattern, <DomainPattern as TryFrom<HostPattern>>::Error>
§impl TryFrom<String> for DomainPattern
impl TryFrom<String> for DomainPattern
impl TryIntoDomainPattern for DomainPattern
impl TryIntoHostPattern for DomainPattern
Auto Trait Implementations§
impl !Freeze for DomainPattern
impl RefUnwindSafe for DomainPattern
impl Send for DomainPattern
impl Sync for DomainPattern
impl Unpin for DomainPattern
impl UnsafeUnpin for DomainPattern
impl UnwindSafe for DomainPattern
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§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>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more