pub struct Label(/* private fields */);
Expand description
Labels are always stored as ASCII, unicode characters must be encoded with punycode
Implementations§
Source§impl Label
impl Label
Sourcepub fn from_raw_bytes(bytes: &[u8]) -> Result<Self, ProtoError>
pub fn from_raw_bytes(bytes: &[u8]) -> Result<Self, ProtoError>
These must only be ASCII, with unicode encoded to PunyCode, or other such transformation.
This uses the bytes as raw ascii values, with nothing escaped on the wire.
Generally users should use from_str
or from_ascii
Sourcepub fn from_utf8(s: &str) -> Result<Self, ProtoError>
pub fn from_utf8(s: &str) -> Result<Self, ProtoError>
Translates this string into IDNA safe name, encoding to punycode as necessary.
Sourcepub fn from_ascii(s: &str) -> Result<Self, ProtoError>
pub fn from_ascii(s: &str) -> Result<Self, ProtoError>
Takes the ascii string and returns a new label.
This will return an Error if the label is not an ascii string
Sourcepub fn to_lowercase(&self) -> Self
pub fn to_lowercase(&self) -> Self
Converts this label to lowercase
Sourcepub fn is_wildcard(&self) -> bool
pub fn is_wildcard(&self) -> bool
Returns true if this label is the wildcard, ‘*’, label
Sourcepub fn as_bytes(&self) -> &[u8] ⓘ
pub fn as_bytes(&self) -> &[u8] ⓘ
Returns the raw bytes of the label, this is good for writing to the wire.
See Display
for presentation version (unescaped from punycode, etc)
Sourcepub fn eq_ignore_ascii_case(&self, other: &Self) -> bool
pub fn eq_ignore_ascii_case(&self, other: &Self) -> bool
Performs the equivalence operation disregarding case
Sourcepub fn cmp_with_f<F: LabelCmp>(&self, other: &Self) -> Ordering
pub fn cmp_with_f<F: LabelCmp>(&self, other: &Self) -> Ordering
compares with the other label, ignoring case
Sourcepub fn to_utf8(&self) -> String
pub fn to_utf8(&self) -> String
Performs the conversion to utf8 from IDNA as necessary, see fmt
for more details
Trait Implementations§
Source§impl IntoLabel for &Label
impl IntoLabel for &Label
Source§fn into_label(self) -> Result<Label, ProtoError>
fn into_label(self) -> Result<Label, ProtoError>
Source§impl IntoLabel for Label
impl IntoLabel for Label
Source§fn into_label(self) -> Result<Label, ProtoError>
fn into_label(self) -> Result<Label, ProtoError>
Source§impl Ord for Label
impl Ord for Label
Source§impl PartialOrd for Label
impl PartialOrd for Label
impl Eq for Label
Auto Trait Implementations§
impl Freeze for Label
impl RefUnwindSafe for Label
impl Send for Label
impl Sync for Label
impl Unpin for Label
impl UnwindSafe for Label
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
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
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
key
and return true
if they are equal.