[][src]Struct mail_headers::_SoftAsciiStr

pub struct _SoftAsciiStr(_);

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:

  1. you would have many unsafe from str conversions/"unnecessary" checks with a strict AsciiStr
  2. 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

Methods

impl SoftAsciiStr[src]

pub fn from_unchecked(s: &str) -> &SoftAsciiStr[src]

pub fn from_str_unchecked(s: &str) -> &SoftAsciiStr[src]

Deprecated since 1.0.0:

use from_unchecked

pub fn from_unchecked_mut(s: &mut str) -> &mut SoftAsciiStr[src]

pub fn from_str(source: &str) -> Result<&SoftAsciiStr, FromSourceError<&str>>[src]

pub fn revalidate_soft_constraint(
    &self
) -> Result<&SoftAsciiStr, FromSourceError<&str>>
[src]

reruns checks if the "is us-ascii" soft constraint is still valid

pub fn as_str(&self) -> &str[src]

pub fn into_soft_ascii_string(self: Box<SoftAsciiStr>) -> SoftAsciiString[src]

pub fn from_boxed_str(bs: Box<str>) -> Box<SoftAsciiStr>[src]

pub fn into_boxed_str(self: Box<SoftAsciiStr>) -> Box<str>[src]

pub fn lines(&self) -> SoftAsciiLines[src]

pub fn split_whitespace(&self) -> SoftAsciiSplitWhitespace[src]

pub fn char_indices(&self) -> SoftAsciiCharIndices[src]

pub fn chars(&self) -> SoftAsciiChars[src]

pub fn split_at(&self, mid: usize) -> (&SoftAsciiStr, &SoftAsciiStr)[src]

pub unsafe fn slice_unchecked(&self, begin: usize, end: usize) -> &SoftAsciiStr[src]

pub fn inner_str_mut(&mut self) -> &mut str[src]

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
[src]

impl SoftAsciiStr[src]

impl SoftAsciiStr[src]

impl SoftAsciiStr[src]

pub fn repeat(&self, n: usize) -> SoftAsciiString[src]

impl SoftAsciiStr[src]

pub fn trim_right(&self) -> &SoftAsciiStr[src]

pub fn trim_left(&self) -> &SoftAsciiStr[src]

pub fn trim(&self) -> &SoftAsciiStr[src]

impl SoftAsciiStr[src]

pub fn len(&self) -> usize[src]

pub fn is_empty(&self) -> bool[src]

pub fn is_char_boundary(&self, index: usize) -> bool[src]

pub fn as_ptr(&self) -> *const u8[src]

pub fn encode_utf16(&self) -> EncodeUtf16[src]

pub fn is_ascii(&self) -> bool[src]

pub fn as_bytes(&self) -> &[u8][src]

Trait Implementations

impl Ord for SoftAsciiStr[src]

fn max(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the minimum of two values. Read more

fn clamp(self, min: Self, max: Self) -> Self[src]

🔬 This is a nightly-only experimental API. (clamp)

Returns max if self is greater than max, and min if self is less than min. Otherwise this will return self. Panics if min > max. Read more

impl Eq for SoftAsciiStr[src]

impl<'a> Default for &'a SoftAsciiStr[src]

impl<'a> PartialEq<Cow<'a, str>> for SoftAsciiStr[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

impl<'a, 'b> PartialEq<Cow<'b, str>> for &'a SoftAsciiStr[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

impl PartialEq<OsString> for SoftAsciiStr[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

impl PartialEq<str> for SoftAsciiStr[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

impl PartialEq<SoftAsciiString> for SoftAsciiStr[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

impl PartialEq<OsStr> for SoftAsciiStr[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

impl PartialEq<SoftAsciiStr> for SoftAsciiStr[src]

impl<'a, 'b> PartialEq<Cow<'a, SoftAsciiStr>> for &'a SoftAsciiStr[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

impl<'a> PartialEq<Cow<'a, SoftAsciiStr>> for SoftAsciiStr[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

impl<'a> PartialEq<OsString> for &'a SoftAsciiStr[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

impl PartialEq<String> for SoftAsciiStr[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

impl<'a> PartialEq<SoftAsciiString> for &'a SoftAsciiStr[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

impl<'a> PartialEq<String> for &'a SoftAsciiStr[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

impl ToSocketAddrs for SoftAsciiStr[src]

type Iter = IntoIter<SocketAddr>

Returned iterator over socket addresses which this type may correspond to. Read more

impl AsRef<SoftAsciiStr> for SoftAsciiStr[src]

impl AsRef<[u8]> for SoftAsciiStr[src]

impl AsRef<OsStr> for SoftAsciiStr[src]

impl AsRef<str> for SoftAsciiStr[src]

impl AsRef<Path> for SoftAsciiStr[src]

impl Display for SoftAsciiStr[src]

impl ToOwned for SoftAsciiStr[src]

type Owned = SoftAsciiString

fn clone_into(&self, target: &mut Self::Owned)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl Hash for SoftAsciiStr[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl Index<RangeTo<usize>> for SoftAsciiStr[src]

type Output = SoftAsciiStr

The returned type after indexing.

impl Index<Range<usize>> for SoftAsciiStr[src]

type Output = SoftAsciiStr

The returned type after indexing.

impl Index<RangeFull> for SoftAsciiStr[src]

type Output = SoftAsciiStr

The returned type after indexing.

impl Index<RangeFrom<usize>> for SoftAsciiStr[src]

type Output = SoftAsciiStr

The returned type after indexing.

impl PartialOrd<SoftAsciiStr> for SoftAsciiStr[src]

impl Debug for SoftAsciiStr[src]

impl PartialEq<SoftAsciiStr> for HeaderName[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]