Struct mail_headers::_SoftAsciiStr
source · pub struct _SoftAsciiStr(_);
Expand description
A str
wrapper adding a “is us-ascii” soft constraint.
This means that it should be ascii but is not guaranteed to be ascii. Which means non ascii chars are not a safety issue just a potential bug.
This is useful for situations where:
- you would have many unsafe from str conversions/“unnecessary” checks with a strict AsciiStr
- you rarely have to strictly rely on the value being ascii
Note
Some functions which should be implemented directly
on SoftAsciiStr
like e.g. trim_matches
are only
provided through .as_str()
. This
is because the Pattern API and SliceIndex API is unstable
i.e. can only be implemented in unstable for now.
Once it gets stabilized (rust #27721/#35729) implementations
can be added
Implementations
sourceimpl SoftAsciiStr
impl SoftAsciiStr
pub fn from_unchecked(s: &str) -> &SoftAsciiStr
pub fn from_str_unchecked(s: &str) -> &SoftAsciiStr
pub fn from_unchecked_mut(s: &mut str) -> &mut SoftAsciiStr
pub fn from_str(source: &str) -> Result<&SoftAsciiStr, FromSourceError<&str>>
sourcepub fn revalidate_soft_constraint(
&self
) -> Result<&SoftAsciiStr, FromSourceError<&str>>
pub fn revalidate_soft_constraint(
&self
) -> Result<&SoftAsciiStr, FromSourceError<&str>>
reruns checks if the “is us-ascii” soft constraint is still valid
pub fn as_str(&self) -> &str
pub fn into_soft_ascii_string(
self: Box<SoftAsciiStr, Global>
) -> SoftAsciiString
pub fn from_boxed_str(bs: Box<str, Global>) -> Box<SoftAsciiStr, Global>
pub fn into_boxed_str(self: Box<SoftAsciiStr, Global>) -> Box<str, Global>
pub fn lines(&self) -> SoftAsciiLines<'_>
pub fn split_whitespace(&self) -> SoftAsciiSplitWhitespace<'_>
pub fn char_indices(&self) -> SoftAsciiCharIndices<'_>
pub fn chars(&self) -> SoftAsciiChars<'_>
pub fn split_at(&self, mid: usize) -> (&SoftAsciiStr, &SoftAsciiStr)
pub unsafe fn slice_unchecked(&self, begin: usize, end: usize) -> &SoftAsciiStr
sourcepub unsafe fn get_unchecked<I>(&self, index: I) -> &SoftAsciiStrwhere
I: TempSliceIndexHelper,
pub unsafe fn get_unchecked<I>(&self, index: I) -> &SoftAsciiStrwhere
I: TempSliceIndexHelper,
Proxy of std::str::get_unchecked
.
Currently limited to the various range types:
Range<usize>
RangeInclusive<usize>
RangeFrom<usize>
RangeTo<usize>
RangeToInclusive<usize>
RangeFull
Once all methods on SliceIndex
are stable this
can be implemented using SliceIndex<SoftAsciiStr>
bounds.
sourcepub fn inner_str_mut(&mut self) -> &mut str
pub fn inner_str_mut(&mut self) -> &mut str
returns a mutable str
reference to the inner buffer
Soft Constraint
be aware that it is very easy to introduce bugs when
directly editing a SoftAsciiStr
as an str
. Still
compared to a AsciiStr implementation this won’t
introduce unsafety, just possible brakeage of the
soft constraint that the data should be ascii.
pub fn parse<F>(&self) -> Result<F, <F as FromStr>::Err>where
F: FromStr,
sourceimpl SoftAsciiStr
impl SoftAsciiStr
pub fn to_lowercase(&self) -> SoftAsciiString
sourceimpl SoftAsciiStr
impl SoftAsciiStr
pub fn to_uppercase(&self) -> SoftAsciiString
sourceimpl SoftAsciiStr
impl SoftAsciiStr
pub fn repeat(&self, n: usize) -> SoftAsciiString
sourceimpl SoftAsciiStr
impl SoftAsciiStr
pub fn trim_right(&self) -> &SoftAsciiStr
pub fn trim_left(&self) -> &SoftAsciiStr
pub fn trim_end(&self) -> &SoftAsciiStr
pub fn trim_start(&self) -> &SoftAsciiStr
pub fn trim(&self) -> &SoftAsciiStr
sourceimpl SoftAsciiStr
impl SoftAsciiStr
Trait Implementations
sourceimpl AsRef<[u8]> for SoftAsciiStr
impl AsRef<[u8]> for SoftAsciiStr
sourceimpl AsRef<OsStr> for SoftAsciiStr
impl AsRef<OsStr> for SoftAsciiStr
sourceimpl AsRef<Path> for SoftAsciiStr
impl AsRef<Path> for SoftAsciiStr
sourceimpl AsRef<SoftAsciiStr> for SoftAsciiStr
impl AsRef<SoftAsciiStr> for SoftAsciiStr
sourcefn as_ref(&self) -> &SoftAsciiStr
fn as_ref(&self) -> &SoftAsciiStr
sourceimpl AsRef<str> for SoftAsciiStr
impl AsRef<str> for SoftAsciiStr
sourceimpl Debug for SoftAsciiStr
impl Debug for SoftAsciiStr
sourceimpl<'a> Default for &'a SoftAsciiStr
impl<'a> Default for &'a SoftAsciiStr
sourcefn default() -> &'a SoftAsciiStr
fn default() -> &'a SoftAsciiStr
sourceimpl Display for SoftAsciiStr
impl Display for SoftAsciiStr
sourceimpl Hash for SoftAsciiStr
impl Hash for SoftAsciiStr
sourceimpl Index<Range<usize>> for SoftAsciiStr
impl Index<Range<usize>> for SoftAsciiStr
sourceimpl Index<RangeFrom<usize>> for SoftAsciiStr
impl Index<RangeFrom<usize>> for SoftAsciiStr
sourceimpl Index<RangeFull> for SoftAsciiStr
impl Index<RangeFull> for SoftAsciiStr
type Output = SoftAsciiStr
type Output = SoftAsciiStr
sourceimpl Index<RangeTo<usize>> for SoftAsciiStr
impl Index<RangeTo<usize>> for SoftAsciiStr
sourceimpl Ord for SoftAsciiStr
impl Ord for SoftAsciiStr
sourceimpl<'a, 'b> PartialEq<Cow<'a, SoftAsciiStr>> for &'a SoftAsciiStr
impl<'a, 'b> PartialEq<Cow<'a, SoftAsciiStr>> for &'a SoftAsciiStr
sourcefn eq(&self, other: &Cow<'a, SoftAsciiStr>) -> bool
fn eq(&self, other: &Cow<'a, SoftAsciiStr>) -> bool
sourceimpl<'a> PartialEq<Cow<'a, SoftAsciiStr>> for SoftAsciiStr
impl<'a> PartialEq<Cow<'a, SoftAsciiStr>> for SoftAsciiStr
sourcefn eq(&self, other: &Cow<'a, SoftAsciiStr>) -> bool
fn eq(&self, other: &Cow<'a, SoftAsciiStr>) -> bool
sourceimpl<'a> PartialEq<Cow<'a, str>> for SoftAsciiStr
impl<'a> PartialEq<Cow<'a, str>> for SoftAsciiStr
sourceimpl<'a, 'b> PartialEq<Cow<'b, str>> for &'a SoftAsciiStr
impl<'a, 'b> PartialEq<Cow<'b, str>> for &'a SoftAsciiStr
sourceimpl PartialEq<SoftAsciiStr> for HeaderName
impl PartialEq<SoftAsciiStr> for HeaderName
sourcefn eq(&self, other: &SoftAsciiStr) -> bool
fn eq(&self, other: &SoftAsciiStr) -> bool
sourceimpl PartialEq<SoftAsciiStr> for OsStr
impl PartialEq<SoftAsciiStr> for OsStr
sourcefn eq(&self, other: &SoftAsciiStr) -> bool
fn eq(&self, other: &SoftAsciiStr) -> bool
sourceimpl PartialEq<SoftAsciiStr> for SoftAsciiStr
impl PartialEq<SoftAsciiStr> for SoftAsciiStr
sourcefn eq(&self, other: &SoftAsciiStr) -> bool
fn eq(&self, other: &SoftAsciiStr) -> bool
sourceimpl<'a> PartialEq<SoftAsciiStr> for str
impl<'a> PartialEq<SoftAsciiStr> for str
sourcefn eq(&self, other: &SoftAsciiStr) -> bool
fn eq(&self, other: &SoftAsciiStr) -> bool
sourceimpl<'a> PartialEq<SoftAsciiString> for &'a SoftAsciiStr
impl<'a> PartialEq<SoftAsciiString> for &'a SoftAsciiStr
sourcefn eq(&self, other: &SoftAsciiString) -> bool
fn eq(&self, other: &SoftAsciiString) -> bool
sourceimpl PartialEq<SoftAsciiString> for SoftAsciiStr
impl PartialEq<SoftAsciiString> for SoftAsciiStr
sourcefn eq(&self, other: &SoftAsciiString) -> bool
fn eq(&self, other: &SoftAsciiString) -> bool
sourceimpl PartialOrd<SoftAsciiStr> for SoftAsciiStr
impl PartialOrd<SoftAsciiStr> for SoftAsciiStr
sourcefn partial_cmp(&self, other: &SoftAsciiStr) -> Option<Ordering>
fn partial_cmp(&self, other: &SoftAsciiStr) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresourceimpl ToOwned for SoftAsciiStr
impl ToOwned for SoftAsciiStr
type Owned = SoftAsciiString
type Owned = SoftAsciiString
sourcefn to_owned(&self) -> SoftAsciiString
fn to_owned(&self) -> SoftAsciiString
1.63.0 · sourcefn clone_into(&self, target: &mut Self::Owned)
fn clone_into(&self, target: &mut Self::Owned)
sourceimpl ToSocketAddrs for SoftAsciiStr
impl ToSocketAddrs for SoftAsciiStr
type Iter = IntoIter<SocketAddr, Global>
type Iter = IntoIter<SocketAddr, Global>
sourcefn to_socket_addrs(&self) -> Result<IntoIter<SocketAddr, Global>, Error>
fn to_socket_addrs(&self) -> Result<IntoIter<SocketAddr, Global>, Error>
SocketAddr
s. Read more