pub struct Raw { /* private fields */ }
Expand description
Helper that allows both to encode and decode strings no matter whether they contain valid or invalid UTF-8.
Regardless of validity the UTF-8 content this type will always be serialized as a string.
Implementations
sourceimpl Raw
impl Raw
sourcepub fn from_utf8(v: Vec<u8>) -> Self
👎 Deprecated: This implementation is unsound and dangerous. See https://github.com/3Hren/msgpack-rust/issues/305
pub fn from_utf8(v: Vec<u8>) -> Self
This implementation is unsound and dangerous. See https://github.com/3Hren/msgpack-rust/issues/305
DO NOT USE. See https://github.com/3Hren/msgpack-rust/issues/305
sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
Returns the string reference if the raw is valid UTF-8, or else None
.
sourcepub fn as_err(&self) -> Option<&Utf8Error>
pub fn as_err(&self) -> Option<&Utf8Error>
Returns the underlying Utf8Error
if the raw contains invalid UTF-8 sequence, or
else None
.
sourcepub fn as_bytes(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn as_bytes(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Returns a byte slice of this raw’s contents.
sourcepub fn into_str(self) -> Option<String>
pub fn into_str(self) -> Option<String>
Consumes this object, yielding the string if the raw is valid UTF-8, or else None
.
sourcepub fn into_bytes(self) -> Vec<u8>
pub fn into_bytes(self) -> Vec<u8>
Converts a Raw
into a byte vector.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Raw
impl<'de> Deserialize<'de> for Raw
sourcefn deserialize<D>(de: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
fn deserialize<D>(de: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Raw
Auto Trait Implementations
impl RefUnwindSafe for Raw
impl Send for Raw
impl Sync for Raw
impl Unpin for Raw
impl UnwindSafe for Raw
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more