Struct bc_ur::prelude::CBOR

source ·
pub struct CBOR(/* private fields */);
Expand description

A symbolic representation of CBOR data.

Implementations§

source§

impl CBOR

source

pub fn case(&self) -> &CBORCase

source§

impl CBOR

Affordances for decoding CBOR from binary representation.

source

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

Decodes the given date into CBOR symbolic representation.

source

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

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

source

pub fn byte_string<T>(data: T) -> CBORwhere T: AsRef<[u8]>,

Create a new CBOR value representing a byte string.

source

pub fn byte_string_hex(hex: &str) -> CBOR

Create a new CBOR value representing a byte string given as a hexadecimal string.

source

pub fn as_byte_string(&self) -> Option<Bytes>

Extract the CBOR value as a byte string.

Returns Some if the value is a byte string, None otherwise.

source

pub fn expect_byte_string(&self) -> Result<Bytes, CBORError>

Extract the CBOR value as a byte string.

Returns Ok if the value is a byte string, Err otherwise.

source

pub fn as_text(&self) -> Option<&str>

Extract the CBOR value as a text string.

Returns Some if the value is a text string, None otherwise.

source

pub fn expect_text(&self) -> Result<&str, CBORError>

Extract the CBOR value as a text string.

Returns Ok if the value is a text string, Err otherwise.

source

pub fn as_array(&self) -> Option<&Vec<CBOR>>

Extract the CBOR value as an array.

Returns Some if the value is an array, None otherwise.

source

pub fn expect_array(&self) -> Result<&Vec<CBOR>, CBORError>

Extract the CBOR value as an array.

Returns Ok if the value is an array, Err otherwise.

source

pub fn as_map(&self) -> Option<&Map>

Extract the CBOR value as a map.

Returns Some if the value is a map, None otherwise.

source

pub fn expect_map(&self) -> Result<&Map, CBORError>

Extract the CBOR value as a map.

Returns Ok if the value is a map, Err otherwise.

source

pub fn tagged_value(tag: impl Into<Tag>, item: impl CBOREncodable) -> CBOR

Create a new CBOR value representing a tagged value.

source

pub fn as_tagged_value(&self) -> Option<(&Tag, &CBOR)>

Extract the CBOR value as a tagged value.

Returns Some if the value is a tagged value, None otherwise.

source

pub fn expect_tagged_value( &self, expected_tag: impl Into<Tag> ) -> Result<&CBOR, CBORError>

Extract the CBOR value as a tagged value.

Returns Ok if the value is a tagged value with the expected tag, Err otherwise.

source

pub fn as_simple_value(&self) -> Option<&Simple>

Extract the CBOR value as a simple value.

Returns Some if the value is a simple value, None otherwise.

source

pub fn expect_simple_value(&self) -> Result<&Simple, CBORError>

Extract the CBOR value as a simple value.

Returns Ok if the value is a simple value, Err otherwise.

source§

impl CBOR

Associated constants for common CBOR simple values.

source

pub fn false() -> CBOR

The CBOR simple value representing false.

source

pub fn true() -> CBOR

The CBOR simple value representing true.

source

pub fn 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, tags: Option<&dyn TagsStoreTrait> ) -> 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, tags: Option<&dyn TagsStoreTrait> ) -> 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 CBORDecodable for CBOR

source§

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

Creates an instance of this type from CBOR symbolic representation.
source§

fn from_cbor_data(cbor_data: &[u8]) -> Result<Self, Error>where Self: Sized,

Creates an instance of this type from encoded CBOR binary data.
source§

impl CBOREncodable for Box<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 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<(), Error>

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

impl Display for CBOR

source§

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

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

impl<T> From<&[T]> for CBORwhere T: CBOREncodable,

source§

fn from(array: &[T]) -> CBOR

Converts to this type from the input type.
source§

impl<T> From<&T> for CBORwhere T: CBOREncodable,

source§

fn from(value: &T) -> CBOR

Converts to this type from the input type.
source§

impl From<&str> for CBOR

source§

fn from(value: &str) -> CBOR

Converts to this type from the input type.
source§

impl<T, const N: usize> From<[T; N]> for CBORwhere T: CBOREncodable,

source§

fn from(array: [T; N]) -> CBOR

Converts to this type from the input type.
source§

impl<K, V> From<BTreeMap<K, V>> for CBORwhere K: CBOREncodable, V: CBOREncodable,

source§

fn from(container: BTreeMap<K, V>) -> CBOR

Converts to this type from the input type.
source§

impl From<Box<CBOR>> for CBOR

source§

fn from(value: Box<CBOR>) -> CBOR

Converts to this type from the input type.
source§

impl From<Bytes> for CBOR

source§

fn from(value: Bytes) -> CBOR

Converts to this type from the input type.
source§

impl From<CBORCase> for CBOR

source§

fn from(case: CBORCase) -> CBOR

Converts to this type from the input type.
source§

impl From<Date> for CBOR

source§

fn from(value: Date) -> CBOR

Converts to this type from the input type.
source§

impl<K, V> From<HashMap<K, V>> for CBORwhere K: CBOREncodable, V: CBOREncodable,

source§

fn from(container: HashMap<K, V>) -> CBOR

Converts to this type from the input type.
source§

impl<T> From<HashSet<T>> for CBORwhere T: CBOREncodable,

source§

fn from(set: HashSet<T>) -> CBOR

Converts to this type from the input type.
source§

impl From<Map> for CBOR

source§

fn from(value: Map) -> CBOR

Converts to this type from the input type.
source§

impl From<Simple> for CBOR

source§

fn from(value: Simple) -> CBOR

Converts to this type from the input type.
source§

impl From<String> for CBOR

source§

fn from(value: String) -> CBOR

Converts to this type from the input type.
source§

impl<T> From<Vec<T>> for CBORwhere T: CBOREncodable,

source§

fn from(vec: Vec<T>) -> CBOR

Converts to this type from the input type.
source§

impl<T> From<VecDeque<T>> for CBORwhere T: CBOREncodable,

source§

fn from(deque: VecDeque<T>) -> CBOR

Converts to this type from the input type.
source§

impl From<bool> for CBOR

source§

fn from(value: bool) -> CBOR

Converts to this type from the input type.
source§

impl From<f16> for CBOR

source§

fn from(value: f16) -> CBOR

Converts to this type from the input type.
source§

impl From<f32> for CBOR

source§

fn from(value: f32) -> CBOR

Converts to this type from the input type.
source§

impl From<f64> for CBOR

source§

fn from(value: f64) -> CBOR

Converts to this type from the input type.
source§

impl From<i16> for CBOR

source§

fn from(value: i16) -> CBOR

Converts to this type from the input type.
source§

impl From<i32> for CBOR

source§

fn from(value: i32) -> CBOR

Converts to this type from the input type.
source§

impl From<i64> for CBOR

source§

fn from(value: i64) -> CBOR

Converts to this type from the input type.
source§

impl From<i8> for CBOR

source§

fn from(value: i8) -> CBOR

Converts to this type from the input type.
source§

impl From<u16> for CBOR

source§

fn from(value: u16) -> CBOR

Converts to this type from the input type.
source§

impl From<u32> for CBOR

source§

fn from(value: u32) -> CBOR

Converts to this type from the input type.
source§

impl From<u64> for CBOR

source§

fn from(value: u64) -> CBOR

Converts to this type from the input type.
source§

impl From<u8> for CBOR

source§

fn from(value: u8) -> CBOR

Converts to this type from the input type.
source§

impl From<usize> for CBOR

source§

fn from(value: usize) -> CBOR

Converts to this type from the input type.
source§

impl PartialEq for CBOR

source§

fn eq(&self, other: &CBOR) -> 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<T> TryFrom<CBOR> for Vec<T>where T: CBORDecodable + Clone,

§

type Error = Error

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

fn try_from(cbor: CBOR) -> Result<Vec<T>, <Vec<T> as TryFrom<CBOR>>::Error>

Performs the conversion.
source§

impl CBORCodable for CBOR

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,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

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.
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.
source§

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

Performs the conversion.