pub struct CharStr<Octs: ?Sized>(/* private fields */);
Expand description
The content of a DNS character string.
A character string consists of up to 255 octets of binary data. This type wraps an octets sequence. It is guaranteed to always be at most 255 octets in length. It derefs into the underlying octets for working with the content in a familiar way.
As per RFC 1035, character strings compare ignoring ASCII case.
CharStr
’s implementations of the std::cmp
traits act accordingly.
Implementations§
source§impl<Octs: ?Sized> CharStr<Octs>
impl<Octs: ?Sized> CharStr<Octs>
sourcepub fn from_octets(octets: Octs) -> Result<Self, CharStrError>
pub fn from_octets(octets: Octs) -> Result<Self, CharStrError>
Creates a new character string from an octets value.
Returns succesfully if octets
can indeed be used as a
character string, i.e., it is not longer than 255 bytes.
sourcepub unsafe fn from_octets_unchecked(octets: Octs) -> Selfwhere
Octs: Sized,
pub unsafe fn from_octets_unchecked(octets: Octs) -> Selfwhere
Octs: Sized,
Creates a character string from octets without length check.
§Safety
The caller has to make sure that octets
is at most 255 octets
long. Otherwise, the behavior is undefined.
source§impl CharStr<[u8]>
impl CharStr<[u8]>
sourcepub fn from_slice(slice: &[u8]) -> Result<&Self, CharStrError>
pub fn from_slice(slice: &[u8]) -> Result<&Self, CharStrError>
Creates a character string from an octets slice.
sourcepub fn empty_slice() -> &'static Self
pub fn empty_slice() -> &'static Self
Creates a new empty character string on an octets slice.
sourcepub unsafe fn from_slice_unchecked(slice: &[u8]) -> &Self
pub unsafe fn from_slice_unchecked(slice: &[u8]) -> &Self
Creates a character string from an octets slice without checking.
§Safety
The caller has to make sure that octets
is at most 255 octets
long. Otherwise, the behaviour is undefined.
source§impl<Octs: ?Sized> CharStr<Octs>
impl<Octs: ?Sized> CharStr<Octs>
sourcepub fn builder() -> CharStrBuilder<Octs::Builder>
pub fn builder() -> CharStrBuilder<Octs::Builder>
Creates a new empty builder for this character string type.
sourcepub fn into_builder(self) -> CharStrBuilder<Octs::Builder>
pub fn into_builder(self) -> CharStrBuilder<Octs::Builder>
Converts the character string into a builder.
sourcepub fn into_octets(self) -> Octswhere
Octs: Sized,
pub fn into_octets(self) -> Octswhere
Octs: Sized,
Converts the character string into its underlying octets value.
sourcepub fn for_slice(&self) -> &CharStr<[u8]>
pub fn for_slice(&self) -> &CharStr<[u8]>
Returns a character string atop a slice of the content.
sourcepub fn for_slice_mut(&mut self) -> &mut CharStr<[u8]>
pub fn for_slice_mut(&mut self) -> &mut CharStr<[u8]>
Returns a character string atop a mutable slice of the content.
sourcepub fn as_slice(&self) -> &[u8] ⓘ
pub fn as_slice(&self) -> &[u8] ⓘ
Returns a reference to a slice of the character string’s data.
sourcepub fn as_slice_mut(&mut self) -> &mut [u8] ⓘ
pub fn as_slice_mut(&mut self) -> &mut [u8] ⓘ
Returns a reference to a mutable slice of the character string’s data.
source§impl<Octs: AsRef<[u8]> + ?Sized> CharStr<Octs>
impl<Octs: AsRef<[u8]> + ?Sized> CharStr<Octs>
source§impl<Octs: AsRef<[u8]> + ?Sized> CharStr<Octs>
impl<Octs: AsRef<[u8]> + ?Sized> CharStr<Octs>
sourcepub fn compose_len(&self) -> u16
pub fn compose_len(&self) -> u16
Returns the length of the wire format representation.
sourcepub fn compose<Target: OctetsBuilder + ?Sized>(
&self,
target: &mut Target,
) -> Result<(), Target::AppendError>
pub fn compose<Target: OctetsBuilder + ?Sized>( &self, target: &mut Target, ) -> Result<(), Target::AppendError>
Appends the wire format representation to an octets builder.
Trait Implementations§
source§impl<T, U> CanonicalOrd<CharStr<U>> for CharStr<T>
impl<T, U> CanonicalOrd<CharStr<U>> for CharStr<T>
source§fn canonical_cmp(&self, other: &CharStr<U>) -> Ordering
fn canonical_cmp(&self, other: &CharStr<U>) -> Ordering
self
and other
.source§fn canonical_lt(&self, other: &Rhs) -> bool
fn canonical_lt(&self, other: &Rhs) -> bool
self
is canonically less than other
.source§fn canonical_le(&self, other: &Rhs) -> bool
fn canonical_le(&self, other: &Rhs) -> bool
self
is canonically less than or equal to other
.source§fn canonical_gt(&self, other: &Rhs) -> bool
fn canonical_gt(&self, other: &Rhs) -> bool
self
is canonically greater than other
.source§fn canonical_ge(&self, other: &Rhs) -> bool
fn canonical_ge(&self, other: &Rhs) -> bool
self
is canonically greater than or equal to other
.source§impl<Octets> FromStr for CharStr<Octets>where
Octets: FromBuilder,
<Octets as FromBuilder>::Builder: OctetsBuilder + FreezeBuilder<Octets = Octets> + EmptyBuilder + AsRef<[u8]>,
impl<Octets> FromStr for CharStr<Octets>where
Octets: FromBuilder,
<Octets as FromBuilder>::Builder: OctetsBuilder + FreezeBuilder<Octets = Octets> + EmptyBuilder + AsRef<[u8]>,
source§impl<Octs, SrcOcts> OctetsFrom<CharStr<SrcOcts>> for CharStr<Octs>where
Octs: OctetsFrom<SrcOcts>,
impl<Octs, SrcOcts> OctetsFrom<CharStr<SrcOcts>> for CharStr<Octs>where
Octs: OctetsFrom<SrcOcts>,
type Error = <Octs as OctetsFrom<SrcOcts>>::Error
source§impl<T, U> PartialOrd<U> for CharStr<T>
impl<T, U> PartialOrd<U> for CharStr<T>
impl<T: AsRef<[u8]> + ?Sized> Eq for CharStr<T>
Auto Trait Implementations§
impl<Octs> Freeze for CharStr<Octs>
impl<Octs> RefUnwindSafe for CharStr<Octs>where
Octs: RefUnwindSafe + ?Sized,
impl<Octs> Send for CharStr<Octs>
impl<Octs> Sync for CharStr<Octs>
impl<Octs> Unpin for CharStr<Octs>
impl<Octs> UnwindSafe for CharStr<Octs>where
Octs: UnwindSafe + ?Sized,
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)