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 as_case(&self) -> &CBORCase

source

pub fn into_case(self) -> CBORCase

source§

impl CBOR

Affordances for decoding CBOR from binary representation.

source

pub fn try_from_data(data: impl AsRef<[u8]>) -> Result<CBOR, Error>

Decodes the given date into CBOR symbolic representation.

source

pub fn try_from_hex(hex: &str) -> Result<CBOR, Error>

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

pub fn to_cbor_data(&self) -> Vec<u8>

source§

impl CBOR

source

pub fn to_byte_string(data: impl AsRef<[u8]>) -> CBOR

Create a new CBOR value representing a byte string.

source

pub fn to_byte_string_from_hex(hex: impl AsRef<str>) -> CBOR

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

Panics if the string is not well-formed hexadecimal.

source

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

Create a new CBOR value representing a tagged value.

source§

impl CBOR

source

pub fn try_into_byte_string(self) -> Result<Bytes, Error>

Extract the CBOR value as a byte string.

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

source

pub fn into_byte_string(self) -> Option<Bytes>

source

pub fn try_into_text(self) -> Result<String, Error>

Extract the CBOR value as a text string.

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

source

pub fn try_into_array(self) -> Result<Vec<CBOR>, Error>

Extract the CBOR value as an array.

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

source

pub fn try_into_map(self) -> Result<Map, Error>

Extract the CBOR value as a map.

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

source

pub fn try_into_tagged_value(self) -> Result<(Tag, CBOR), Error>

Extract the CBOR value as a tagged value.

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

source

pub fn try_into_expected_tagged_value( self, expected_tag: impl Into<Tag>, ) -> Result<CBOR, Error>

Extract the CBOR value as an expected tagged value.

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

source

pub fn try_into_simple_value(self) -> Result<Simple, Error>

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 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 CBOR
where T: Into<CBOR> + Clone,

source§

fn from(array: &[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 CBOR
where T: Into<CBOR>,

source§

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

Converts to this type from the input type.
source§

impl<K, V> From<BTreeMap<K, V>> for CBOR
where K: Into<CBOR>, V: Into<CBOR>,

source§

fn from(container: BTreeMap<K, V>) -> 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 CBOR
where K: Into<CBOR>, V: Into<CBOR>,

source§

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

Converts to this type from the input type.
source§

impl<T> From<HashSet<T>> for CBOR
where T: Into<CBOR>,

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 From<UR> for CBOR

source§

fn from(ur: UR) -> Self

Converts to this type from the input type.
source§

impl<T> From<Vec<T>> for CBOR
where T: Into<CBOR>,

source§

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

Converts to this type from the input type.
source§

impl<T> From<VecDeque<T>> for CBOR
where T: Into<CBOR>,

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: TryFrom<CBOR, Error = Error> + Clone,

§

type Error = Error

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

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

Performs the conversion.

Auto Trait Implementations§

§

impl Freeze for CBOR

§

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 T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> CBOREncodable for T
where T: Into<CBOR> + Clone,

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where 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 T
where 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 T
where 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 T
where 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 T
where 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.
source§

impl<T> CBORCodable for T

source§

impl<T> CBORDecodable for T
where T: TryFrom<CBOR>,