pub struct Label<'a> { /* private fields */ }
Expand description
Represents a label in a domain name
A valid label is consists of A-Z, a-z, 0-9, and hyphen (-), and must be at most 63 characters in length. This library also considers valid any label starting with underscore (_), to be able to parse mDNS domain names.
Microsoft implementation allows unicode characters in the label content.
To create a label with unicode characters, use Label::new_unchecked
The Display
implementation uses std::string::String::from_utf8_lossy
to display the
label.
Implementations§
Source§impl<'a> Label<'a>
impl<'a> Label<'a>
Sourcepub fn new<T: Into<Cow<'a, [u8]>>>(data: T) -> Result<Self>
pub fn new<T: Into<Cow<'a, [u8]>>>(data: T) -> Result<Self>
Create a new Label
if given data is valid and within the limits
Sourcepub fn new_unchecked<T: Into<Cow<'a, [u8]>>>(data: T) -> Self
pub fn new_unchecked<T: Into<Cow<'a, [u8]>>>(data: T) -> Self
Create a new Label without checking for size limits or valid content. This function can be used to create labels with unicode characters
Sourcepub fn into_owned<'b>(self) -> Label<'b>
pub fn into_owned<'b>(self) -> Label<'b>
Transforms the inner data into its owned type
Trait Implementations§
impl<'a> Eq for Label<'a>
impl<'a> StructuralPartialEq for Label<'a>
Auto Trait Implementations§
impl<'a> Freeze for Label<'a>
impl<'a> RefUnwindSafe for Label<'a>
impl<'a> Send for Label<'a>
impl<'a> Sync for Label<'a>
impl<'a> Unpin for Label<'a>
impl<'a> UnwindSafe for Label<'a>
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