Struct rmp_serde::RawRef
[−]
[src]
pub struct RawRef<'a> { /* fields omitted */ }
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.
Methods
impl<'a> RawRef<'a>
[src]
fn new(v: &'a str) -> Self
[src]
Constructs a new RawRef
from the UTF-8 string.
fn from_utf8(v: &'a [u8]) -> Self
[src]
Converts a vector of bytes to a RawRef
.
fn is_str(&self) -> bool
[src]
Returns true
if the raw is valid UTF-8.
fn is_err(&self) -> bool
[src]
Returns true
if the raw contains invalid UTF-8 sequence.
fn as_str(&self) -> Option<&str>
[src]
Returns the string reference if the raw is valid UTF-8, or else None
.
fn as_err(&self) -> Option<&Utf8Error>
[src]
Returns the underlying Utf8Error
if the raw contains invalid UTF-8 sequence, or
else None
.
fn as_bytes(&self) -> &[u8]
[src]
Returns a byte slice of this raw's contents.
Trait Implementations
impl<'a> Clone for RawRef<'a>
[src]
fn clone(&self) -> RawRef<'a>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<'a> Copy for RawRef<'a>
[src]
impl<'a> Debug for RawRef<'a>
[src]
impl<'a> PartialEq for RawRef<'a>
[src]
fn eq(&self, __arg_0: &RawRef<'a>) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &RawRef<'a>) -> bool
[src]
This method tests for !=
.
impl<'a> Serialize for RawRef<'a>
[src]
fn serialize<S>(&self, se: S) -> Result<S::Ok, S::Error> where
S: Serializer,
[src]
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl<'de> Deserialize<'de> for RawRef<'de>
[src]
fn deserialize<D>(de: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more