Struct neovim_lib::Utf8String [−][src]
pub struct Utf8String { /* fields omitted */ }Represents an UTF-8 MessagePack string type.
According to the MessagePack spec, string objects may contain invalid byte sequence and the behavior of a deserializer depends on the actual implementation when it received invalid byte sequence. Deserializers should provide functionality to get the original byte array so that applications can decide how to handle the object.
Summarizing, it's prohibited to instantiate a string type with invalid UTF-8 sequences, however
it is possible to obtain an underlying bytes that were attempted to convert to a String. This
may happen when trying to unpack strings that were decoded using older MessagePack spec with
raw types instead of string/binary.
Methods
impl Utf8String[src]
impl Utf8Stringpub fn is_str(&self) -> bool[src]
pub fn is_str(&self) -> boolReturns true if the string is valid UTF-8.
pub fn is_err(&self) -> bool[src]
pub fn is_err(&self) -> boolReturns true if the string contains invalid UTF-8 sequence.
pub fn as_str(&self) -> Option<&str>[src]
pub fn as_str(&self) -> Option<&str>Returns the string reference if the string is valid UTF-8, or else None.
pub fn as_err(&self) -> Option<&Utf8Error>[src]
pub fn as_err(&self) -> Option<&Utf8Error>Returns the underlying Utf8Error if the string contains invalud UTF-8 sequence, or
else None.
pub fn as_bytes(&self) -> &[u8][src]
pub fn as_bytes(&self) -> &[u8]Returns a byte slice of this Utf8String's contents.
pub fn into_str(self) -> Option<String>[src]
pub fn into_str(self) -> Option<String>Consumes this object, yielding the string if the string is valid UTF-8, or else None.
pub fn into_bytes(self) -> Vec<u8>[src]
pub fn into_bytes(self) -> Vec<u8>Converts a Utf8String into a byte vector.
Trait Implementations
impl Clone for Utf8String[src]
impl Clone for Utf8Stringfn clone(&self) -> Utf8String[src]
fn clone(&self) -> Utf8StringReturns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
impl Debug for Utf8String[src]
impl Debug for Utf8Stringfn fmt(&self, f: &mut Formatter) -> Result<(), Error>[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>Formats the value using the given formatter. Read more
impl<'a> From<Cow<'a, str>> for Utf8String[src]
impl<'a> From<Cow<'a, str>> for Utf8Stringfn from(val: Cow<'a, str>) -> Utf8String[src]
fn from(val: Cow<'a, str>) -> Utf8StringPerforms the conversion.
impl<'a> From<&'a str> for Utf8String[src]
impl<'a> From<&'a str> for Utf8Stringfn from(val: &str) -> Utf8String[src]
fn from(val: &str) -> Utf8StringPerforms the conversion.
impl<'a> From<String> for Utf8String[src]
impl<'a> From<String> for Utf8Stringfn from(val: String) -> Utf8String[src]
fn from(val: String) -> Utf8StringPerforms the conversion.
impl<'a> Into<Utf8String> for Utf8StringRef<'a>[src]
impl<'a> Into<Utf8String> for Utf8StringRef<'a>fn into(self) -> Utf8String[src]
fn into(self) -> Utf8StringPerforms the conversion.
impl Display for Utf8String[src]
impl Display for Utf8Stringfn fmt(&self, fmt: &mut Formatter) -> Result<(), Error>[src]
fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error>Formats the value using the given formatter. Read more
impl PartialEq<Utf8String> for Utf8String[src]
impl PartialEq<Utf8String> for Utf8Stringfn eq(&self, other: &Utf8String) -> bool[src]
fn eq(&self, other: &Utf8String) -> boolThis method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &Utf8String) -> bool[src]
fn ne(&self, other: &Utf8String) -> boolThis method tests for !=.
Auto Trait Implementations
impl Send for Utf8String
impl Send for Utf8Stringimpl Sync for Utf8String
impl Sync for Utf8String