pub struct Subname(/* private fields */);Expand description
The label part of an RRset name, relative to the zone.
The API spells the zone apex two different ways: "" in a JSON payload, and @ in a
URL path. They are not interchangeable — an empty path segment collapses under HTTP
path normalization, so /rrsets//A/ does not reach the apex — and since the API
returns "", code that round-trips an RRset has to translate rather than
substitute. That translation is this type’s whole reason for existing:
as_payload for bodies, as_path for URLs.
use desec::Subname;
let apex = Subname::apex();
assert_eq!(apex.as_payload(), "");
assert_eq!(apex.as_path(), "@");
let www: Subname = "www".parse()?;
assert_eq!(www.as_payload(), "www");
assert_eq!(www.as_path(), "www");Implementations§
Source§impl Subname
impl Subname
Sourcepub fn new(subname: impl Into<String>) -> Result<Self, InvalidValue>
pub fn new(subname: impl Into<String>) -> Result<Self, InvalidValue>
Validates and wraps a subname.
Accepts "" and "@" as the apex, so a value read from either a payload or a
path can be passed straight in.
Sourcepub fn as_payload(&self) -> &str
pub fn as_payload(&self) -> &str
The spelling to put in a JSON body: "" at the apex.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Subname
impl<'de> Deserialize<'de> for Subname
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Subname
Source§impl Ord for Subname
impl Ord for Subname
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for Subname
impl PartialOrd for Subname
impl StructuralPartialEq for Subname
Auto Trait Implementations§
impl Freeze for Subname
impl RefUnwindSafe for Subname
impl Send for Subname
impl Sync for Subname
impl Unpin for Subname
impl UnsafeUnpin for Subname
impl UnwindSafe for Subname
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,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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.