Skip to main content

ProtoStringCow

Enum ProtoStringCow 

Source
pub enum ProtoStringCow<'a> {
    Borrowed(View<'a, ProtoString>),
    Owned(ProtoString),
}

Variants§

§

Borrowed(View<'a, ProtoString>)

§

Owned(ProtoString)

Methods from Deref<Target = ProtoStr>§

Source

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

Converts self to a byte slice.

Note: this type does not implement Deref; you must call as_bytes() or AsRef<[u8]> to get access to bytes.

Source

pub fn to_str(&self) -> Result<&str, Utf8Error>

Yields a &str slice if self contains valid UTF-8.

This may perform a runtime check, dependent on runtime.

String::from_utf8_lossy(proto_str.as_bytes()) can be used to infallibly construct a string, replacing invalid UTF-8 with U+FFFD REPLACEMENT CHARACTER.

Source

pub fn to_cow_lossy(&self) -> Cow<'_, str>

Converts self to a string, including invalid characters.

Invalid UTF-8 sequences are replaced with U+FFFD REPLACEMENT CHARACTER.

Users should be prefer this to .to_string() provided by Display. .to_cow_lossy() is the same operation, but it may avoid an allocation if the string is already UTF-8.

Source

pub fn is_empty(&self) -> bool

Returns true if self has a length of zero bytes.

Source

pub fn len(&self) -> usize

Returns the length of self.

Like &str, this is a length in bytes, not chars or graphemes.

Source

pub fn is_ascii(&self) -> bool

Source

pub fn contains<T>(&self, other: &T) -> bool
where T: AsRef<[u8]> + ?Sized,

Source

pub fn starts_with<T>(&self, other: &T) -> bool
where T: AsRef<[u8]> + ?Sized,

Source

pub fn ends_with<T>(&self, other: &T) -> bool
where T: AsRef<[u8]> + ?Sized,

Source

pub fn find<T>(&self, other: &T) -> Option<usize>
where T: AsRef<[u8]> + ?Sized,

Source

pub fn trim_ascii(&self) -> &Self

Source

pub fn trim_ascii_start(&self) -> &Self

Source

pub fn trim_ascii_end(&self) -> &Self

Trait Implementations§

Source§

impl AsRef<[u8]> for ProtoStringCow<'_>

Source§

fn as_ref(&self) -> &[u8] ⓘ

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

impl<'msg> AsView for ProtoStringCow<'msg>

Source§

type Proxied = ProtoStringCord

Source§

fn as_view(&self) -> ProtoStringCow<'_>

Converts a borrow into a View with the lifetime of that borrow. Read more
Source§

impl<'a> Debug for ProtoStringCow<'a>

Source§

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

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

impl<'a> Deref for ProtoStringCow<'a>

Source§

type Target = ProtoStr

The resulting type after dereferencing.
Source§

fn deref(&self) -> View<'_, ProtoString>

Dereferences the value.
Source§

impl IntoProxied<ProtoString> for ProtoStringCow<'_>

Source§

impl<'msg> IntoView<'msg> for ProtoStringCow<'msg>

Source§

fn into_view<'shorter>(self) -> ProtoStringCow<'shorter>
where 'msg: 'shorter,

Converts into a View with a potentially shorter lifetime. Read more
Source§

impl PartialEq<ProtoStringCow<'_>> for ProtoStringCow<'_>

Source§

fn eq(&self, rhs: &ProtoStringCow<'_>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl PartialEq<ProtoStringCow<'_>> for str

Source§

fn eq(&self, rhs: &ProtoStringCow<'_>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl PartialEq<str> for ProtoStringCow<'_>

Source§

fn eq(&self, rhs: &str) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<'msg> SealedInternal for ProtoStringCow<'msg>

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for ProtoStringCow<'a>

§

impl<'a> Forget for ProtoStringCow<'a>

§

impl<'a> Freeze for ProtoStringCow<'a>

§

impl<'a> Move for ProtoStringCow<'a>

§

impl<'a> Send for ProtoStringCow<'a>

§

impl<'a> Sync for ProtoStringCow<'a>

§

impl<'a> Unpin for ProtoStringCow<'a>

§

impl<'a> UnsafeUnpin for ProtoStringCow<'a>

§

impl<'a> UnwindSafe for ProtoStringCow<'a>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.