Enum InnerAscii

Source
pub enum InnerAscii {
    Owned(SoftAsciiString),
    Shared(OwningRef<'static, Arc<String>, SoftAsciiStr>),
}
Expand description

InnerAscii is string data container which can contain either a owned SoftAsciiString or a SoftAsciiStr reference into a shared string buffer.

Variants§

§

Owned(SoftAsciiString)

§

Shared(OwningRef<'static, Arc<String>, SoftAsciiStr>)

Implementations§

Source§

impl InnerAscii

Source

pub fn into_shared(self) -> Self

converts this container into on which uses underlying shared data

if the data is already shared nothing is done. If not the owned data is converted into the underlying string buffer and OwningRef is used to enable the shared reference

Note that the underlying buffer is no an SoftAsciiString but a String (from which we happend to know that it fulfills the “is us-ascii” soft constraint). This allows us to have an InnerAscii share data with a possible non us-ascii string buffer as long as the part accessable through the SoftAsciiStr is ascii. Or at last should be ascii as it’s a soft constraint.

Source§

impl InnerAscii

Source

pub fn new<S: Into<SoftAsciiString>>(data: S) -> Self

Source§

impl InnerAscii

Source

pub fn as_str(&self) -> &str

Methods from Deref<Target = SoftAsciiStr>§

Source

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

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

Source

pub fn as_str(&self) -> &str

Source

pub fn lines(&self) -> SoftAsciiLines<'_>

Source

pub fn split_whitespace(&self) -> SoftAsciiSplitWhitespace<'_>

Source

pub fn char_indices(&self) -> SoftAsciiCharIndices<'_>

Source

pub fn chars(&self) -> SoftAsciiChars<'_>

Source

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

Source

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

👎Deprecated since 1.1.0: deprecated in std
Source

pub unsafe fn get_unchecked<I>(&self, index: I) -> &SoftAsciiStr
where 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.

Source

pub fn parse<F>(&self) -> Result<F, <F as FromStr>::Err>
where F: FromStr,

Source

pub fn to_lowercase(&self) -> SoftAsciiString

Source

pub fn to_uppercase(&self) -> SoftAsciiString

Source

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

Source

pub fn trim_right(&self) -> &SoftAsciiStr

👎Deprecated since 1.1.0: deprecated in std
Source

pub fn trim_left(&self) -> &SoftAsciiStr

👎Deprecated since 1.1.0: deprecated in std
Source

pub fn trim_end(&self) -> &SoftAsciiStr

Source

pub fn trim_start(&self) -> &SoftAsciiStr

Source

pub fn trim(&self) -> &SoftAsciiStr

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

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

Source

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

Source

pub fn encode_utf16(&self) -> EncodeUtf16<'_>

Source

pub fn is_ascii(&self) -> bool

Source

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

Trait Implementations§

Source§

impl AsRef<str> for InnerAscii

Source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for InnerAscii

Source§

fn clone(&self) -> InnerAscii

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for InnerAscii

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for InnerAscii

Source§

type Target = SoftAsciiStr

The resulting type after dereferencing.
Source§

fn deref(&self) -> &SoftAsciiStr

Dereferences the value.
Source§

impl<'de> Deserialize<'de> for InnerAscii

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<SoftAsciiString> for InnerAscii

Source§

fn from(data: SoftAsciiString) -> Self

Converts to this type from the input type.
Source§

impl Hash for InnerAscii

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

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

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Into<SoftAsciiString> for InnerAscii

Source§

fn into(self) -> SoftAsciiString

Converts this type into the (usually inferred) input type.
Source§

impl PartialEq for InnerAscii

Source§

fn eq(&self, other: &InnerAscii) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for InnerAscii

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for InnerAscii

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> HeaderTryFrom<T> for T

Source§

impl<F, T> HeaderTryInto<T> for F
where T: HeaderTryFrom<F>,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,