Struct saltpig::extensions::cbor::EncodedCbor [−][src]
pub struct EncodedCbor(_);
An extension type for embedded encoded CBOR items (tag value 24; RFC 7049, section 2.4.4.1).
(Note that this is really just a newtype of Vec<u8>
, and no checking at
all is done to see if the wrapped bytes even remotely resemble an encoded
CBOR item.)
Methods
impl EncodedCbor
[src]
impl EncodedCbor
pub fn new(bytes: Vec<u8>) -> EncodedCbor
[src]
pub fn new(bytes: Vec<u8>) -> EncodedCbor
Constructs an EncodedCbor
from the raw bytes it wraps.
As mentioned in the type-level docs, no checking is done to see if the bytes are actually valid CBOR data.
pub fn extract(value: Value) -> Result<EncodedCbor, TypeError>
[src]
pub fn extract(value: Value) -> Result<EncodedCbor, TypeError>
Attempts to parse an EncodedCbor
value out of a Value
(returning
Err if the value turns out to be something other than an EncodedCbor
).
pub fn encode_value(value: Value) -> EncodedCbor
[src]
pub fn encode_value(value: Value) -> EncodedCbor
Constructs an EncodedCbor
by encoding a Value
.
pub fn into_inner(self) -> Vec<u8>
[src]
pub fn into_inner(self) -> Vec<u8>
Unwraps this EncodedCbor
, returning the underlying bytes.
pub fn embed(self) -> Value
[src]
pub fn embed(self) -> Value
Renders self
into a generic CBOR value.
Returns a Value
representing self
's encoded bytes with a tag value
of 24.
pub fn decode(&self) -> Result<Value, Error>
[src]
pub fn decode(&self) -> Result<Value, Error>
Attempts to decode the encoded CBOR item.
This is a convenience method that simply calls Value::from_bytes()
on the underlying bytes stored in self
.
Trait Implementations
impl Debug for EncodedCbor
[src]
impl Debug for EncodedCbor
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Clone for EncodedCbor
[src]
impl Clone for EncodedCbor
fn clone(&self) -> EncodedCbor
[src]
fn clone(&self) -> EncodedCbor
Returns 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 Extension for EncodedCbor
[src]
impl Extension for EncodedCbor
impl From<EncodedCbor> for Value
[src]
impl From<EncodedCbor> for Value
Renders self
into a generic CBOR value.
Equivalent to EncodedCbor::embed()
.
fn from(encoded_cbor: EncodedCbor) -> Value
[src]
fn from(encoded_cbor: EncodedCbor) -> Value
Performs the conversion.
impl TryFrom<Value> for EncodedCbor
[src]
impl TryFrom<Value> for EncodedCbor
Attempts to parse an EncodedCbor
value out of a Value
.
Equivalent to EncodedCbor::extract()
.
type Error = TypeError
try_from
)The type returned in the event of a conversion error.
fn try_from(value: Value) -> Result<EncodedCbor, TypeError>
[src]
fn try_from(value: Value) -> Result<EncodedCbor, TypeError>
try_from
)Performs the conversion.
impl From<Vec<u8>> for EncodedCbor
[src]
impl From<Vec<u8>> for EncodedCbor
Constructs an EncodedCbor
from the raw bytes it wraps.
Equivalent to EncodedCbor::new()
.
fn from(bytes: Vec<u8>) -> EncodedCbor
[src]
fn from(bytes: Vec<u8>) -> EncodedCbor
Performs the conversion.
impl From<EncodedCbor> for Vec<u8>
[src]
impl From<EncodedCbor> for Vec<u8>
Unwraps this EncodedCbor
, returning the underlying bytes.
Equivalent to EncodedCbor::into_inner()
fn from(encoded_cbor: EncodedCbor) -> Vec<u8>
[src]
fn from(encoded_cbor: EncodedCbor) -> Vec<u8>
Performs the conversion.
Auto Trait Implementations
impl Send for EncodedCbor
impl Send for EncodedCbor
impl Sync for EncodedCbor
impl Sync for EncodedCbor