pub struct CharStr<Octs: ?Sized>(_);
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>where
Octs: AsRef<[u8]> + Sized,
pub fn from_octets(octets: Octs) -> Result<Self, CharStrError>where Octs: AsRef<[u8]> + Sized,
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>where
Octs: IntoBuilder,
Octs::Builder: EmptyBuilder,
pub fn builder() -> CharStrBuilder<Octs::Builder>where Octs: IntoBuilder, Octs::Builder: EmptyBuilder,
Creates a new empty builder for this character string type.
sourcepub fn into_builder(self) -> CharStrBuilder<Octs::Builder>where
Octs: IntoBuilder + Sized,
<Octs as IntoBuilder>::Builder: AsRef<[u8]>,
pub fn into_builder(self) -> CharStrBuilder<Octs::Builder>where Octs: IntoBuilder + Sized, <Octs as IntoBuilder>::Builder: AsRef<[u8]>,
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]>where
Octs: AsRef<[u8]>,
pub fn for_slice(&self) -> &CharStr<[u8]>where Octs: AsRef<[u8]>,
Returns a character string atop a slice of the content.
sourcepub fn for_slice_mut(&mut self) -> &mut CharStr<[u8]>where
Octs: AsMut<[u8]>,
pub fn for_slice_mut(&mut self) -> &mut CharStr<[u8]>where Octs: AsMut<[u8]>,
Returns a character string atop a mutable slice of the content.
sourcepub fn as_slice(&self) -> &[u8] ⓘwhere
Octs: AsRef<[u8]>,
pub fn as_slice(&self) -> &[u8] ⓘwhere Octs: AsRef<[u8]>,
Returns a reference to a 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>where
T: AsRef<[u8]> + ?Sized,
U: AsRef<[u8]> + ?Sized,
impl<T, U> CanonicalOrd<CharStr<U>> for CharStr<T>where T: AsRef<[u8]> + ?Sized, U: AsRef<[u8]> + ?Sized,
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> PartialEq<U> for CharStr<T>where
T: AsRef<[u8]> + ?Sized,
U: AsRef<[u8]> + ?Sized,
impl<T, U> PartialEq<U> for CharStr<T>where T: AsRef<[u8]> + ?Sized, U: AsRef<[u8]> + ?Sized,
source§impl<T, U> PartialOrd<U> for CharStr<T>where
T: AsRef<[u8]> + ?Sized,
U: AsRef<[u8]> + ?Sized,
impl<T, U> PartialOrd<U> for CharStr<T>where T: AsRef<[u8]> + ?Sized, U: AsRef<[u8]> + ?Sized,
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more