Struct Domain
pub struct Domain(/* private fields */);
Expand description
A domain.
§Remarks
The validation of domains created by this type is very shallow. Proper validation is offloaded to other services such as DNS resolvers.
Implementations§
§impl Domain
impl Domain
pub const fn from_static(s: &'static str) -> Domain
pub const fn from_static(s: &'static str) -> Domain
Creates a domain at compile time.
This function requires the static string to be a valid domain
§Panics
This function panics at compile time when the static string is not a valid domain.
pub fn tld_private() -> Domain
pub fn tld_private() -> Domain
Create an new apex Domain
(TLD) meant for loopback purposes.
As proposed in https://itp.cdn.icann.org/en/files/security-and-stability-advisory-committee-ssac-reports/sac-113-en.pdf.
In specific this means that it will match on any domain with the TLD .internal
.
pub fn tld_localhost() -> Domain
pub fn tld_localhost() -> Domain
Creates the localhost Domain
.
pub fn is_wildcard(&self) -> bool
pub fn is_wildcard(&self) -> bool
Returns true
if this domain is a wildcard domain.
pub fn as_wildcard_parent(&self) -> Option<Domain>
pub fn as_wildcard_parent(&self) -> Option<Domain>
Returns the parent of this wildcard domain,
in case it is indeed a wildcast domain,
otherwise None
is returned.
Use Self::is_wildcard
if you just wish to check
it is is a wildcard domain, as it is cheaper to use.
pub fn is_parent_of(&self, other: &Domain) -> bool
pub fn is_parent_of(&self, other: &Domain) -> bool
pub fn have_same_registrable_domain(&self, other: &Domain) -> bool
pub fn have_same_registrable_domain(&self, other: &Domain) -> bool
Compare the registrable domain
§Example
use rama_net::address::Domain;
assert!(Domain::from_static("www.example.com")
.have_same_registrable_domain(&Domain::from_static("example.com")));
assert!(Domain::from_static("example.com")
.have_same_registrable_domain(&Domain::from_static("www.example.com")));
assert!(Domain::from_static("a.example.com")
.have_same_registrable_domain(&Domain::from_static("b.example.com")));
assert!(Domain::from_static("example.com")
.have_same_registrable_domain(&Domain::from_static("example.com")));
Trait Implementations§
§impl<'de> Deserialize<'de> for Domain
impl<'de> Deserialize<'de> for Domain
§fn deserialize<D>(
deserializer: D,
) -> Result<Domain, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Domain, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
§impl Ord for Domain
impl Ord for Domain
§impl PartialOrd<&str> for Domain
impl PartialOrd<&str> for Domain
§impl PartialOrd<Domain> for &str
impl PartialOrd<Domain> for &str
§impl PartialOrd<Domain> for String
impl PartialOrd<Domain> for String
§impl PartialOrd<Domain> for str
impl PartialOrd<Domain> for str
§impl PartialOrd<String> for Domain
impl PartialOrd<String> for Domain
§impl PartialOrd<str> for Domain
impl PartialOrd<str> for Domain
§impl PartialOrd for Domain
impl PartialOrd for Domain
§impl Serialize for Domain
impl Serialize for Domain
§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
impl Eq for Domain
Auto Trait Implementations§
impl Freeze for Domain
impl RefUnwindSafe for Domain
impl Send for Domain
impl Sync for Domain
impl Unpin for Domain
impl UnwindSafe for Domain
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§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> 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§impl<T, U> RamaTryFrom<T> for Uwhere
U: TryFrom<T>,
impl<T, U> RamaTryFrom<T> for Uwhere
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
fn rama_try_from(value: T) -> Result<U, <U as RamaTryFrom<T>>::Error>
§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> ToSmolStr for T
impl<T> ToSmolStr for T
fn to_smolstr(&self) -> SmolStr
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string
, but without panic on OOM.