pub struct AnsName { /* private fields */ }Expand description
A validated ANS name, split into its domain and optional subdomain.
Construct one with AnsName::parse, which enforces the ANS validation
rules and strips a trailing .apt.
§Example
use aptos_sdk::api::ans::AnsName;
let name = AnsName::parse("alice.apt")?;
assert_eq!(name.domain(), "alice");
assert_eq!(name.subdomain(), None);
let sub = AnsName::parse("wallet.alice.apt")?;
assert_eq!(sub.domain(), "alice");
assert_eq!(sub.subdomain(), Some("wallet"));Implementations§
Source§impl AnsName
impl AnsName
Sourcepub fn parse(name: &str) -> AptosResult<Self>
pub fn parse(name: &str) -> AptosResult<Self>
Parses and validates an ANS name.
Accepts names with or without a trailing .apt, and either a bare
domain (alice) or a subdomain.domain (wallet.alice).
§Errors
Returns an error if the name has more than two segments or any segment
violates the ANS rules (3-63 characters of lowercase a-z, 0-9, and
non-leading/trailing hyphens).
Sourcepub fn is_subdomain(&self) -> bool
pub fn is_subdomain(&self) -> bool
Returns true if this name has a subdomain.
Trait Implementations§
impl Eq for AnsName
impl StructuralPartialEq for AnsName
Auto Trait Implementations§
impl Freeze for AnsName
impl RefUnwindSafe for AnsName
impl Send for AnsName
impl Sync for AnsName
impl Unpin for AnsName
impl UnsafeUnpin for AnsName
impl UnwindSafe for AnsName
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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
Checks if this value is equivalent to the given key. Read more
§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
Compare self to
key and return true if they are equal.§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>
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§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.