Struct HostPattern
pub struct HostPattern(/* private fields */);net only.Expand description
A compiled pattern for matching a Host.
The representation is intentionally private. Construct patterns explicitly
with exact, sub, or
try_glob, or parse conventional syntax through
try_new.
use rama_net::address::{Domain, Host, HostPattern};
let pattern = HostPattern::sub(Domain::from_static("example.com"));
assert!(pattern.matches(Host::from_static("api.example.com").view()));
assert!(!pattern.matches(Host::LOCALHOST_IPV4.view()));Implementations§
§impl HostPattern
impl HostPattern
pub const fn exact(host: Host) -> HostPattern
pub const fn exact(host: Host) -> HostPattern
Match exactly one host.
This constructor performs no parsing.
pub fn sub(domain: Domain) -> HostPattern
pub fn sub(domain: Domain) -> HostPattern
Match a domain and all of its descendants.
This constructor performs no parsing.
pub fn try_glob(
pattern: impl Into<Cow<'static, str>>,
) -> Result<HostPattern, Box<dyn Error + Sync + Send>>
pub fn try_glob( pattern: impl Into<Cow<'static, str>>, ) -> Result<HostPattern, Box<dyn Error + Sync + Send>>
Compile a flat case-insensitive host glob.
* matches any sequence of bytes, including dots. Matching is ASCII
case-insensitive against HostRef::to_str, so a glob can match
domain names and IP literals alike. A static string is borrowed by the
compiled wildcard; an owned String transfers its allocation.
pub fn try_new(
pattern: impl TryIntoHostPattern,
) -> Result<HostPattern, Box<dyn Error + Sync + Send>>
pub fn try_new( pattern: impl TryIntoHostPattern, ) -> Result<HostPattern, Box<dyn Error + Sync + Send>>
Parse a host pattern.
Plain hosts are exact, .example.com and *.example.com are domain
subtree patterns, and other values containing * are flat host globs.
Trait Implementations§
§impl Clone for HostPattern
impl Clone for HostPattern
§fn clone(&self) -> HostPattern
fn clone(&self) -> HostPattern
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 HostPattern
impl Debug for HostPattern
§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 HostPattern
impl FromStr for HostPattern
§impl TryFrom<Box<str>> for HostPattern
impl TryFrom<Box<str>> for HostPattern
§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 HostPattern
impl TryFrom<String> for HostPattern
impl TryIntoHostPattern for HostPattern
Auto Trait Implementations§
impl !Freeze for HostPattern
impl RefUnwindSafe for HostPattern
impl Send for HostPattern
impl Sync for HostPattern
impl Unpin for HostPattern
impl UnsafeUnpin for HostPattern
impl UnwindSafe for HostPattern
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