Struct rmpv::Utf8StringRef

source ·
pub struct Utf8StringRef<'a> { /* private fields */ }
Expand description

A non-owning evil twin of Utf8String. Does exactly the same thing except ownership.

Implementations§

source§

impl<'a> Utf8StringRef<'a>

source

pub fn is_str(&self) -> bool

Returns true if the string is valid UTF-8.

source

pub fn is_err(&self) -> bool

Returns true if the string contains invalid UTF-8 sequence.

source

pub fn as_str(&self) -> Option<&str>

Returns the string reference if the string is valid UTF-8, or else None.

source

pub fn as_err(&self) -> Option<&Utf8Error>

Returns the underlying Utf8Error if the string contains invalud UTF-8 sequence, or else None.

source

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

Returns a byte slice of this string contents no matter whether it’s valid or not UTF-8.

source

pub fn into_string(self) -> Option<String>

Consumes this object, yielding the string if the string is valid UTF-8, or else None.

source

pub fn into_str(self) -> Option<&'a str>

Consumes this object, yielding the string reference if the string is valid UTF-8, or else None.

source

pub fn into_bytes(self) -> Vec<u8>

Converts a Utf8StringRef into a byte vector.

Trait Implementations§

source§

impl<'a> Clone for Utf8StringRef<'a>

source§

fn clone(&self) -> Utf8StringRef<'a>

Returns a copy 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<'a> Debug for Utf8StringRef<'a>

source§

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

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

impl<'a> Display for Utf8StringRef<'a>

source§

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

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

impl<'a> From<&'a str> for Utf8StringRef<'a>

source§

fn from(val: &'a str) -> Self

Converts to this type from the input type.
source§

impl<'a> From<Utf8StringRef<'a>> for Utf8String

source§

fn from(val: Utf8StringRef<'a>) -> Self

Converts to this type from the input type.
source§

impl<'a> PartialEq for Utf8StringRef<'a>

source§

fn eq(&self, other: &Utf8StringRef<'a>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a> TryFrom<ValueRef<'a>> for Utf8StringRef<'a>

§

type Error = ValueRef<'a>

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

fn try_from(val: ValueRef<'a>) -> Result<Utf8StringRef<'a>, Self::Error>

Performs the conversion.
source§

impl<'a> Copy for Utf8StringRef<'a>

source§

impl<'a> StructuralPartialEq for Utf8StringRef<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Utf8StringRef<'a>

§

impl<'a> RefUnwindSafe for Utf8StringRef<'a>

§

impl<'a> Send for Utf8StringRef<'a>

§

impl<'a> Sync for Utf8StringRef<'a>

§

impl<'a> Unpin for Utf8StringRef<'a>

§

impl<'a> UnwindSafe for Utf8StringRef<'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<T> ToOwned for T
where T: Clone,

§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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>,

§

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.