Skip to main content

AsDomainRef

Trait AsDomainRef 

pub trait AsDomainRef: AsDomainRefPrivate {
    // Provided methods
    fn as_wildcard_parent(&self) -> Option<Domain> { ... }
    fn to_domain(&self) -> Domain { ... }
    fn to_wildcard(&self) -> Result<Domain, PushError> { ... }
    fn as_wildcard(&self) -> Option<Domain> { ... }
}
Available on crate feature net only.
Expand description

A trait which is used by the rama-net crate for places where we wish to have access to a reference to a Domain, directly or indirectly, for non-move purposes.

For example to compare it, or use it in a derived form.

Provided Methods§

fn as_wildcard_parent(&self) -> Option<Domain>

fn to_domain(&self) -> Domain

Return an owned Domain.

For &'static str inputs this validates and panics on invalid input (matching Domain::from_static); for Domain it clones cheaply.

fn to_wildcard(&self) -> Result<Domain, PushError>

Return this value in wildcard form (*.x).

If self is already a wildcard, an owned copy is returned as-is. Otherwise this is equivalent to self.to_domain().try_as_wildcard() — i.e. x becomes *.x (with the usual length cap).

§Errors

Returns PushError if the resulting name would exceed MAX_NAME_LEN.

§Panics

Inherited from Self::to_domain: for &'static str inputs this panics on invalid domain syntax (matching Domain::from_static).

fn as_wildcard(&self) -> Option<Domain>

If self is already in wildcard form, return it as an owned Domain; otherwise return None.

Unlike Self::to_wildcard, this does not transform bare inputs into the wildcard form — use it when you want to know “was this input already a wildcard?” without doing any conversion.

Implementations on Foreign Types§

§

impl AsDomainRef for &'static str

§

impl<T> AsDomainRef for &T
where T: AsDomainRefPrivate,

Implementors§