Enum dcbor::CBOR

source ·
pub enum CBOR {
    Unsigned(u64),
    Negative(i64),
    Bytes(Bytes),
    Text(String),
    Array(Vec<CBOR>),
    Map(Map),
    Tagged(Tag, Box<CBOR>),
    Simple(Simple),
}
Expand description

A symbolic representation of CBOR data.

Variants§

§

Unsigned(u64)

Unsigned integer (major type 0).

§

Negative(i64)

Negative integer (major type 1).

§

Bytes(Bytes)

Byte string (major type 2).

§

Text(String)

UTF-8 string (major type 3).

§

Array(Vec<CBOR>)

Array (major type 4).

§

Map(Map)

Map (major type 5).

§

Tagged(Tag, Box<CBOR>)

Tagged value (major type 6).

§

Simple(Simple)

Simple value (major type 7).

Implementations§

source§

impl CBOR

Affordances for decoding CBOR from binary representation.

source

pub fn from_data(data: &[u8]) -> Result<CBOR, DecodeError>

Decodes the given date into CBOR symbolic representation.

source

pub fn from_hex(hex: &str) -> Result<CBOR, DecodeError>

Decodes the given data into CBOR symbolic representation given as a hexadecimal string.

Panics if the string is not well-formed hexadecimal with no spaces or other characters.

source§

impl CBOR

Associated constants for common CBOR simple values.

source

pub const FALSE: CBOR = _

The CBOR simple value representing false.

source

pub const TRUE: CBOR = _

The CBOR simple value representing true.

source

pub const NULL: CBOR = _

The CBOR simple value representing null (None).

source§

impl CBOR

Affordances for viewing CBOR in diagnostic notation.

source

pub fn diagnostic_opt( &self, annotate: bool, known_tags: Option<&dyn KnownTags> ) -> String

Returns a representation of this CBOR in diagnostic notation.

Optionally annotates the output, e.g. formatting dates and adding names of known tags.

source

pub fn diagnostic(&self) -> String

Returns a representation of this CBOR in diagnostic notation.

source§

impl CBOR

Affordances for viewing the encoded binary representation of CBOR as hexadecimal.

source

pub fn hex(&self) -> String

Returns the encoded hexadecimal representation of this CBOR.

source

pub fn hex_opt( &self, annotate: bool, known_tags: Option<&dyn KnownTags> ) -> String

Returns the encoded hexadecimal representation of this CBOR.

Optionally annotates the output, e.g. breaking the output up into semantically meaningful lines, formatting dates, and adding names of known tags.

Trait Implementations§

source§

impl CBOREncodable for CBOR

source§

fn cbor(&self) -> CBOR

Returns the value in CBOR symbolic representation.
source§

fn cbor_data(&self) -> Vec<u8>

Returns the value in CBOR binary representation.
source§

impl Clone for CBOR

source§

fn clone(&self) -> CBOR

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 Debug for CBOR

source§

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

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

impl Display for CBOR

source§

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

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

impl From<&Bytes> for CBOR

source§

fn from(value: &Bytes) -> Self

Converts to this type from the input type.
source§

impl From<&bool> for CBOR

source§

fn from(value: &bool) -> Self

Converts to this type from the input type.
source§

impl From<&f32> for CBOR

source§

fn from(value: &f32) -> Self

Converts to this type from the input type.
source§

impl From<&f64> for CBOR

source§

fn from(value: &f64) -> Self

Converts to this type from the input type.
source§

impl From<&i16> for CBOR

source§

fn from(value: &i16) -> Self

Converts to this type from the input type.
source§

impl From<&i32> for CBOR

source§

fn from(value: &i32) -> Self

Converts to this type from the input type.
source§

impl From<&i64> for CBOR

source§

fn from(value: &i64) -> Self

Converts to this type from the input type.
source§

impl From<&i8> for CBOR

source§

fn from(value: &i8) -> Self

Converts to this type from the input type.
source§

impl From<&str> for CBOR

source§

fn from(value: &str) -> Self

Converts to this type from the input type.
source§

impl From<&u16> for CBOR

source§

fn from(value: &u16) -> Self

Converts to this type from the input type.
source§

impl From<&u32> for CBOR

source§

fn from(value: &u32) -> Self

Converts to this type from the input type.
source§

impl From<&u64> for CBOR

source§

fn from(value: &u64) -> Self

Converts to this type from the input type.
source§

impl From<&u8> for CBOR

source§

fn from(value: &u8) -> Self

Converts to this type from the input type.
source§

impl From<&usize> for CBOR

source§

fn from(value: &usize) -> Self

Converts to this type from the input type.
source§

impl From<Bytes> for CBOR

source§

fn from(value: Bytes) -> Self

Converts to this type from the input type.
source§

impl From<CBOR> for Bytes

source§

fn from(value: CBOR) -> Self

Converts to this type from the input type.
source§

impl From<CBOR> for String

source§

fn from(value: CBOR) -> Self

Converts to this type from the input type.
source§

impl From<CBOR> for bool

source§

fn from(value: CBOR) -> Self

Converts to this type from the input type.
source§

impl From<CBOR> for f32

source§

fn from(value: CBOR) -> Self

Converts to this type from the input type.
source§

impl From<CBOR> for f64

source§

fn from(value: CBOR) -> Self

Converts to this type from the input type.
source§

impl From<CBOR> for i16

source§

fn from(value: CBOR) -> Self

Converts to this type from the input type.
source§

impl From<CBOR> for i32

source§

fn from(value: CBOR) -> Self

Converts to this type from the input type.
source§

impl From<CBOR> for i64

source§

fn from(value: CBOR) -> Self

Converts to this type from the input type.
source§

impl From<CBOR> for i8

source§

fn from(value: CBOR) -> Self

Converts to this type from the input type.
source§

impl From<CBOR> for u16

source§

fn from(value: CBOR) -> Self

Converts to this type from the input type.
source§

impl From<CBOR> for u32

source§

fn from(value: CBOR) -> Self

Converts to this type from the input type.
source§

impl From<CBOR> for u64

source§

fn from(value: CBOR) -> Self

Converts to this type from the input type.
source§

impl From<CBOR> for u8

source§

fn from(value: CBOR) -> Self

Converts to this type from the input type.
source§

impl From<CBOR> for usize

source§

fn from(value: CBOR) -> Self

Converts to this type from the input type.
source§

impl From<String> for CBOR

source§

fn from(value: String) -> Self

Converts to this type from the input type.
source§

impl From<bool> for CBOR

source§

fn from(value: bool) -> Self

Converts to this type from the input type.
source§

impl From<f32> for CBOR

source§

fn from(value: f32) -> Self

Converts to this type from the input type.
source§

impl From<f64> for CBOR

source§

fn from(value: f64) -> Self

Converts to this type from the input type.
source§

impl From<i16> for CBOR

source§

fn from(value: i16) -> Self

Converts to this type from the input type.
source§

impl From<i32> for CBOR

source§

fn from(value: i32) -> Self

Converts to this type from the input type.
source§

impl From<i64> for CBOR

source§

fn from(value: i64) -> Self

Converts to this type from the input type.
source§

impl From<i8> for CBOR

source§

fn from(value: i8) -> Self

Converts to this type from the input type.
source§

impl From<u16> for CBOR

source§

fn from(value: u16) -> Self

Converts to this type from the input type.
source§

impl From<u32> for CBOR

source§

fn from(value: u32) -> Self

Converts to this type from the input type.
source§

impl From<u64> for CBOR

source§

fn from(value: u64) -> Self

Converts to this type from the input type.
source§

impl From<u8> for CBOR

source§

fn from(value: u8) -> Self

Converts to this type from the input type.
source§

impl From<usize> for CBOR

source§

fn from(value: usize) -> Self

Converts to this type from the input type.
source§

impl PartialEq<CBOR> for CBOR

source§

fn eq(&self, other: &Self) -> 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 TryFrom<&[u8]> for CBOR

§

type Error = DecodeError

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

fn try_from(value: &[u8]) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<&CBOR> for Bytes

§

type Error = DecodeError

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

fn try_from(value: &CBOR) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<&CBOR> for String

§

type Error = DecodeError

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

fn try_from(value: &CBOR) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<&CBOR> for bool

§

type Error = DecodeError

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

fn try_from(value: &CBOR) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<&CBOR> for f32

§

type Error = DecodeError

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

fn try_from(cbor: &CBOR) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<&CBOR> for f64

§

type Error = DecodeError

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

fn try_from(cbor: &CBOR) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<&CBOR> for i16

§

type Error = DecodeError

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

fn try_from(value: &CBOR) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<&CBOR> for i32

§

type Error = DecodeError

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

fn try_from(value: &CBOR) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<&CBOR> for i64

§

type Error = DecodeError

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

fn try_from(value: &CBOR) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<&CBOR> for i8

§

type Error = DecodeError

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

fn try_from(value: &CBOR) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<&CBOR> for u16

§

type Error = DecodeError

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

fn try_from(value: &CBOR) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<&CBOR> for u32

§

type Error = DecodeError

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

fn try_from(value: &CBOR) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<&CBOR> for u64

§

type Error = DecodeError

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

fn try_from(value: &CBOR) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<&CBOR> for u8

§

type Error = DecodeError

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

fn try_from(value: &CBOR) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<&CBOR> for usize

§

type Error = DecodeError

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

fn try_from(value: &CBOR) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl RefUnwindSafe for CBOR

§

impl Send for CBOR

§

impl Sync for CBOR

§

impl Unpin for CBOR

§

impl UnwindSafe for CBOR

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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 Twhere 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 Twhere 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.