pub enum ProtoStringCow<'a> {
Borrowed(View<'a, ProtoString>),
Owned(ProtoString),
}Variants§
Borrowed(View<'a, ProtoString>)
Owned(ProtoString)
Methods from Deref<Target = ProtoStr>§
Sourcepub fn as_bytes(&self) -> &[u8] ⓘ
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.
Sourcepub fn to_str(&self) -> Result<&str, Utf8Error>
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.
Sourcepub fn to_cow_lossy(&self) -> Cow<'_, str>
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.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the length of self.
Like &str, this is a length in bytes, not chars or graphemes.
pub fn is_ascii(&self) -> bool
pub fn contains<T>(&self, other: &T) -> bool
pub fn starts_with<T>(&self, other: &T) -> bool
pub fn ends_with<T>(&self, other: &T) -> bool
pub fn find<T>(&self, other: &T) -> Option<usize>
pub fn trim_ascii(&self) -> &Self
pub fn trim_ascii_start(&self) -> &Self
pub fn trim_ascii_end(&self) -> &Self
Trait Implementations§
Source§impl AsRef<[u8]> for ProtoStringCow<'_>
impl AsRef<[u8]> for ProtoStringCow<'_>
Source§impl<'msg> AsView for ProtoStringCow<'msg>
impl<'msg> AsView for ProtoStringCow<'msg>
Source§impl<'a> Debug for ProtoStringCow<'a>
impl<'a> Debug for ProtoStringCow<'a>
Source§impl<'a> Deref for ProtoStringCow<'a>
impl<'a> Deref for ProtoStringCow<'a>
impl IntoProxied<ProtoString> for ProtoStringCow<'_>
Source§impl<'msg> IntoView<'msg> for ProtoStringCow<'msg>
impl<'msg> IntoView<'msg> for ProtoStringCow<'msg>
Source§fn into_view<'shorter>(self) -> ProtoStringCow<'shorter>where
'msg: 'shorter,
fn into_view<'shorter>(self) -> ProtoStringCow<'shorter>where
'msg: 'shorter,
View with a potentially shorter lifetime. Read more