pub enum HostDetails {
Domain(DomainDetails),
Ipv4(Ipv4Details),
Ipv6(Ipv6Details),
}Expand description
The details of a BetterUrl’s host.
Variants§
Domain(DomainDetails)
Details of a BetterUrl’s domain host.
Ipv4(Ipv4Details)
Details of a BetterUrl’s IPv4 host.
Ipv6(Ipv6Details)
Details of a BetterUrl’s IPv6 host.
Implementations§
Source§impl HostDetails
impl HostDetails
Sourcepub fn parse(host: &str) -> Result<HostDetails, ParseError>
pub fn parse(host: &str) -> Result<HostDetails, ParseError>
Gets the details of a host str.
§Errors
If the call to url::Host::parse returns an error, that error is returned.
§Examples
use better_url::*;
assert!(matches!(HostDetails::parse("example.com").unwrap(), HostDetails::Domain(_)));
assert!(matches!(HostDetails::parse("127.0.0.1" ).unwrap(), HostDetails::Ipv4 (_)));
assert!(matches!(HostDetails::parse("[::1]" ).unwrap(), HostDetails::Ipv6 (_)));Sourcepub fn from_ipv4_addr(addr: Ipv4Addr) -> HostDetails
pub fn from_ipv4_addr(addr: Ipv4Addr) -> HostDetails
Sourcepub fn from_ipv6_addr(addr: Ipv6Addr) -> HostDetails
pub fn from_ipv6_addr(addr: Ipv6Addr) -> HostDetails
Sourcepub fn from_ip_addr(addr: IpAddr) -> HostDetails
pub fn from_ip_addr(addr: IpAddr) -> HostDetails
Sourcepub fn from_host<T>(host: &Host<T>) -> HostDetails
pub fn from_host<T>(host: &Host<T>) -> HostDetails
Gets the details of a url::Host.
Assumes url::Host::Domain always contains valid domains, which isn’t true, but is true enough to work.
§Examples
use url::Host;
use better_url::*;
assert!(matches!(HostDetails::from_host(&Host::parse("example.com").unwrap()), HostDetails::Domain(_)));
assert!(matches!(HostDetails::from_host(&Host::parse("127.0.0.1" ).unwrap()), HostDetails::Ipv4 (_)));
assert!(matches!(HostDetails::from_host(&Host::parse("[::1]" ).unwrap()), HostDetails::Ipv6 (_)));Sourcepub fn domain_details(&self) -> Option<&DomainDetails>
pub fn domain_details(&self) -> Option<&DomainDetails>
If self is Self::Domain, return it.
§Examples
use better_url::*;
assert!(matches!(HostDetails::parse("example.com").unwrap().domain_details(), Some(_)));
assert!(matches!(HostDetails::parse("127.0.0.1" ).unwrap().domain_details(), None ));
assert!(matches!(HostDetails::parse("[::1]" ).unwrap().domain_details(), None ));Sourcepub fn ipv4_details(&self) -> Option<&Ipv4Details>
pub fn ipv4_details(&self) -> Option<&Ipv4Details>
If self is Self::Ipv4, return it.
§Examples
use better_url::*;
assert!(matches!(HostDetails::parse("example.com").unwrap().ipv4_details(), None ));
assert!(matches!(HostDetails::parse("127.0.0.1" ).unwrap().ipv4_details(), Some(_)));
assert!(matches!(HostDetails::parse("[::1]" ).unwrap().ipv4_details(), None ));Sourcepub fn ipv6_details(&self) -> Option<&Ipv6Details>
pub fn ipv6_details(&self) -> Option<&Ipv6Details>
If self is Self::Ipv6, return it.
§Examples
use better_url::*;
assert!(matches!(HostDetails::parse("example.com").unwrap().ipv6_details(), None ));
assert!(matches!(HostDetails::parse("127.0.0.1" ).unwrap().ipv6_details(), None ));
assert!(matches!(HostDetails::parse("[::1]" ).unwrap().ipv6_details(), Some(_)));Trait Implementations§
Source§impl Clone for HostDetails
impl Clone for HostDetails
Source§fn clone(&self) -> HostDetails
fn clone(&self) -> HostDetails
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for HostDetails
impl Debug for HostDetails
Source§impl<'de> Deserialize<'de> for HostDetails
impl<'de> Deserialize<'de> for HostDetails
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<HostDetails, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<HostDetails, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<DomainDetails> for HostDetails
impl From<DomainDetails> for HostDetails
Source§fn from(value: DomainDetails) -> HostDetails
fn from(value: DomainDetails) -> HostDetails
Converts to this type from the input type.
Source§impl From<Ipv4Details> for HostDetails
impl From<Ipv4Details> for HostDetails
Source§fn from(value: Ipv4Details) -> HostDetails
fn from(value: Ipv4Details) -> HostDetails
Converts to this type from the input type.
Source§impl From<Ipv6Details> for HostDetails
impl From<Ipv6Details> for HostDetails
Source§fn from(value: Ipv6Details) -> HostDetails
fn from(value: Ipv6Details) -> HostDetails
Converts to this type from the input type.
Source§impl FromStr for HostDetails
impl FromStr for HostDetails
Source§type Err = ParseError
type Err = ParseError
The associated error which can be returned from parsing.
Source§fn from_str(s: &str) -> Result<HostDetails, <HostDetails as FromStr>::Err>
fn from_str(s: &str) -> Result<HostDetails, <HostDetails as FromStr>::Err>
Parses a string
s to return a value of this type. Read moreSource§impl PartialEq for HostDetails
impl PartialEq for HostDetails
Source§impl Serialize for HostDetails
impl Serialize for HostDetails
Source§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,
Serialize this value into the given Serde serializer. Read more
Source§impl TryFrom<HostDetails> for DomainDetails
impl TryFrom<HostDetails> for DomainDetails
Source§type Error = HostIsNotDomain
type Error = HostIsNotDomain
The type returned in the event of a conversion error.
Source§fn try_from(
value: HostDetails,
) -> Result<DomainDetails, <DomainDetails as TryFrom<HostDetails>>::Error>
fn try_from( value: HostDetails, ) -> Result<DomainDetails, <DomainDetails as TryFrom<HostDetails>>::Error>
Performs the conversion.
Source§impl TryFrom<HostDetails> for Ipv4Details
impl TryFrom<HostDetails> for Ipv4Details
Source§type Error = HostIsNotIpv4
type Error = HostIsNotIpv4
The type returned in the event of a conversion error.
Source§fn try_from(
value: HostDetails,
) -> Result<Ipv4Details, <Ipv4Details as TryFrom<HostDetails>>::Error>
fn try_from( value: HostDetails, ) -> Result<Ipv4Details, <Ipv4Details as TryFrom<HostDetails>>::Error>
Performs the conversion.
Source§impl TryFrom<HostDetails> for Ipv6Details
impl TryFrom<HostDetails> for Ipv6Details
Source§type Error = HostIsNotIpv6
type Error = HostIsNotIpv6
The type returned in the event of a conversion error.
Source§fn try_from(
value: HostDetails,
) -> Result<Ipv6Details, <Ipv6Details as TryFrom<HostDetails>>::Error>
fn try_from( value: HostDetails, ) -> Result<Ipv6Details, <Ipv6Details as TryFrom<HostDetails>>::Error>
Performs the conversion.
impl Copy for HostDetails
impl Eq for HostDetails
impl StructuralPartialEq for HostDetails
Auto Trait Implementations§
impl Freeze for HostDetails
impl RefUnwindSafe for HostDetails
impl Send for HostDetails
impl Sync for HostDetails
impl Unpin for HostDetails
impl UnwindSafe for HostDetails
Blanket Implementations§
Source§impl<T> AggregateExpressionMethods for T
impl<T> AggregateExpressionMethods for T
Source§fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
DISTINCT modifier for aggregate functions Read moreSource§fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
ALL modifier for aggregate functions Read moreSource§fn aggregate_filter<P>(self, f: P) -> Self::Output
fn aggregate_filter<P>(self, f: P) -> Self::Output
Add an aggregate function filter Read more
Source§fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
Add an aggregate function order Read more
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,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.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> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
Convert
self to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
Convert
&self to an expression for Diesel’s query builder. Read moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> WindowExpressionMethods for T
impl<T> WindowExpressionMethods for T
Source§fn over(self) -> Self::Outputwhere
Self: OverDsl,
fn over(self) -> Self::Outputwhere
Self: OverDsl,
Turn a function call into a window function call Read more
Source§fn window_filter<P>(self, f: P) -> Self::Output
fn window_filter<P>(self, f: P) -> Self::Output
Add a filter to the current window function Read more
Source§fn partition_by<E>(self, expr: E) -> Self::Outputwhere
Self: PartitionByDsl<E>,
fn partition_by<E>(self, expr: E) -> Self::Outputwhere
Self: PartitionByDsl<E>,
Add a partition clause to the current window function Read more
Source§fn window_order<E>(self, expr: E) -> Self::Outputwhere
Self: OrderWindowDsl<E>,
fn window_order<E>(self, expr: E) -> Self::Outputwhere
Self: OrderWindowDsl<E>,
Add a order clause to the current window function Read more