pub struct HostPattern(/* private fields */);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§
Source§impl HostPattern
impl HostPattern
Sourcepub const fn exact(host: Host) -> Self
pub const fn exact(host: Host) -> Self
Match exactly one host.
This constructor performs no parsing.
Sourcepub fn sub(domain: Domain) -> Self
pub fn sub(domain: Domain) -> Self
Match a domain and all of its descendants.
This constructor performs no parsing.
Sourcepub fn try_glob(pattern: impl Into<Cow<'static, str>>) -> Result<Self, BoxError>
pub fn try_glob(pattern: impl Into<Cow<'static, str>>) -> Result<Self, BoxError>
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.
Sourcepub fn try_new(pattern: impl TryIntoHostPattern) -> Result<Self, BoxError>
pub fn try_new(pattern: impl TryIntoHostPattern) -> Result<Self, BoxError>
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§
Source§impl Clone for HostPattern
impl Clone for HostPattern
Source§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 moreSource§impl Debug for HostPattern
impl Debug for HostPattern
Source§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.
Source§fn from(pattern: DomainPattern) -> Self
fn from(pattern: DomainPattern) -> Self
Source§impl FromStr for HostPattern
impl FromStr for HostPattern
Source§impl TryFrom<HostPattern> for DomainPattern
impl TryFrom<HostPattern> for DomainPattern
Source§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§
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,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T, U> RamaTryFrom<T> for Uwhere
U: TryFrom<T>,
impl<T, U> RamaTryFrom<T> for Uwhere
U: TryFrom<T>,
Source§impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for Twhere
U: RamaTryFrom<T, CrateMarker>,
impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for Twhere
U: RamaTryFrom<T, CrateMarker>,
type Error = <U as RamaTryFrom<T, CrateMarker>>::Error
fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T, CrateMarker>>::Error>
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<V, F> ValueFormatter<&V> for F
impl<V, F> ValueFormatter<&V> for F
Source§const SHAPE: FieldShape<'static>
const SHAPE: FieldShape<'static>
metrique_require_explicit_impls only.Source§fn format_value(writer: impl ValueWriter, value: &&V)
fn format_value(writer: impl ValueWriter, value: &&V)
value to writerSource§impl<V, F> ValueFormatter<Arc<V>> for F
impl<V, F> ValueFormatter<Arc<V>> for F
Source§const SHAPE: FieldShape<'static>
const SHAPE: FieldShape<'static>
metrique_require_explicit_impls only.Source§fn format_value(writer: impl ValueWriter, value: &Arc<V>)
fn format_value(writer: impl ValueWriter, value: &Arc<V>)
value to writerSource§impl<V, F> ValueFormatter<Box<V>> for F
impl<V, F> ValueFormatter<Box<V>> for F
Source§const SHAPE: FieldShape<'static>
const SHAPE: FieldShape<'static>
metrique_require_explicit_impls only.Source§fn format_value(writer: impl ValueWriter, value: &Box<V>)
fn format_value(writer: impl ValueWriter, value: &Box<V>)
value to writerSource§impl<V, F> ValueFormatter<Cow<'_, V>> for F
impl<V, F> ValueFormatter<Cow<'_, V>> for F
Source§const SHAPE: FieldShape<'static>
const SHAPE: FieldShape<'static>
metrique_require_explicit_impls only.Source§fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)
fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)
value to writerSource§impl<V, F> ValueFormatter<Option<V>> for Fwhere
F: ValueFormatter<V> + ?Sized,
impl<V, F> ValueFormatter<Option<V>> for Fwhere
F: ValueFormatter<V> + ?Sized,
Source§const SHAPE: FieldShape<'static>
const SHAPE: FieldShape<'static>
metrique_require_explicit_impls only.Source§fn format_value(writer: impl ValueWriter, value: &Option<V>)
fn format_value(writer: impl ValueWriter, value: &Option<V>)
value to writer