pub struct CBOR(/* private fields */);Expand description
A symbolic representation of CBOR data.
Implementations§
Source§impl CBOR
impl CBOR
Affordances for decoding CBOR from binary representation.
Sourcepub fn try_from_data(data: impl AsRef<[u8]>) -> Result<CBOR, Error>
pub fn try_from_data(data: impl AsRef<[u8]>) -> Result<CBOR, Error>
Decodes the given date into CBOR symbolic representation.
Sourcepub fn try_from_hex(hex: &str) -> Result<CBOR, Error>
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.
pub fn to_cbor_data(&self) -> Vec<u8> ⓘ
Source§impl CBOR
impl CBOR
Sourcepub fn to_byte_string(data: impl AsRef<[u8]>) -> CBOR
pub fn to_byte_string(data: impl AsRef<[u8]>) -> CBOR
Create a new CBOR value representing a byte string.
Sourcepub fn to_byte_string_from_hex(hex: impl AsRef<str>) -> CBOR
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§impl CBOR
impl CBOR
Sourcepub fn try_into_byte_string(self) -> Result<Vec<u8>, Error>
pub fn try_into_byte_string(self) -> Result<Vec<u8>, Error>
Extract the CBOR value as a byte string.
Returns Ok if the value is a byte string, Err otherwise.
pub fn into_byte_string(self) -> Option<Vec<u8>>
Sourcepub fn try_into_text(self) -> Result<String, Error>
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.
Sourcepub fn try_into_array(self) -> Result<Vec<CBOR>, Error>
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.
Sourcepub fn try_into_map(self) -> Result<Map, Error>
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.
Sourcepub fn try_into_tagged_value(self) -> Result<(Tag, CBOR), Error>
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.
Sourcepub fn try_into_expected_tagged_value(
self,
expected_tag: impl Into<Tag>,
) -> Result<CBOR, Error>
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.
Sourcepub fn try_into_simple_value(self) -> Result<Simple, Error>
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
impl CBOR
Affordances for viewing CBOR in diagnostic notation.
Sourcepub fn diagnostic_opt(
&self,
annotate: bool,
summarize: bool,
flat: bool,
tags: Option<&dyn TagsStoreTrait>,
) -> String
pub fn diagnostic_opt( &self, annotate: bool, summarize: bool, flat: 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.
Sourcepub fn diagnostic(&self) -> String
pub fn diagnostic(&self) -> String
Returns a representation of this CBOR in diagnostic notation.
Sourcepub fn diagnostic_annotated(&self) -> String
pub fn diagnostic_annotated(&self) -> String
Returns a representation of this CBOR in diagnostic notation, with annotations.
pub fn diagnostic_flat(&self) -> String
pub fn summary(&self) -> String
pub fn summary_opt(&self, tags: &dyn TagsStoreTrait) -> String
Source§impl CBOR
impl CBOR
Affordances for viewing the encoded binary representation of CBOR as hexadecimal.
Sourcepub fn hex_opt(
&self,
annotate: bool,
tags: Option<&dyn TagsStoreTrait>,
) -> String
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.
Sourcepub fn hex_annotated(&self) -> String
pub fn hex_annotated(&self) -> String
Returns the encoded hexadecimal representation of this CBOR, with annotations.
Trait Implementations§
Source§impl EnvelopeEncodable for CBOR
impl EnvelopeEncodable for CBOR
fn into_envelope(self) -> Envelope
fn to_envelope(&self) -> Envelopewhere
Self: Clone,
Source§impl EnvelopeFormat for CBOR
impl EnvelopeFormat for CBOR
fn format_item(&self, context: &FormatContext) -> EnvelopeFormatItem
Source§impl EnvelopeSummary for CBOR
impl EnvelopeSummary for CBOR
fn envelope_summary( &self, max_length: usize, context: &FormatContext, ) -> Result<String>
Source§impl From<AgreementPrivateKey> for CBOR
impl From<AgreementPrivateKey> for CBOR
Source§fn from(value: AgreementPrivateKey) -> CBOR
fn from(value: AgreementPrivateKey) -> CBOR
Source§impl From<AgreementPublicKey> for CBOR
impl From<AgreementPublicKey> for CBOR
Source§fn from(value: AgreementPublicKey) -> CBOR
fn from(value: AgreementPublicKey) -> CBOR
Source§impl From<AuthenticationTag> for CBOR
impl From<AuthenticationTag> for CBOR
Source§fn from(value: AuthenticationTag) -> CBOR
fn from(value: AuthenticationTag) -> CBOR
Source§impl From<ByteString> for CBOR
impl From<ByteString> for CBOR
Source§fn from(value: ByteString) -> CBOR
fn from(value: ByteString) -> CBOR
Source§impl From<Compressed> for CBOR
impl From<Compressed> for CBOR
Source§fn from(value: Compressed) -> CBOR
fn from(value: Compressed) -> CBOR
Source§impl From<ECPrivateKey> for CBOR
impl From<ECPrivateKey> for CBOR
Source§fn from(value: ECPrivateKey) -> CBOR
fn from(value: ECPrivateKey) -> CBOR
Source§impl From<ECPublicKey> for CBOR
impl From<ECPublicKey> for CBOR
Source§fn from(value: ECPublicKey) -> CBOR
fn from(value: ECPublicKey) -> CBOR
Source§impl From<ECUncompressedPublicKey> for CBOR
impl From<ECUncompressedPublicKey> for CBOR
Source§fn from(value: ECUncompressedPublicKey) -> CBOR
fn from(value: ECUncompressedPublicKey) -> CBOR
Source§impl From<EncryptedMessage> for CBOR
impl From<EncryptedMessage> for CBOR
Source§fn from(value: EncryptedMessage) -> CBOR
fn from(value: EncryptedMessage) -> CBOR
Source§impl From<KnownValue> for CBOR
impl From<KnownValue> for CBOR
Source§fn from(value: KnownValue) -> Self
fn from(value: KnownValue) -> Self
Source§impl From<PrivateKeyBase> for CBOR
impl From<PrivateKeyBase> for CBOR
Source§fn from(value: PrivateKeyBase) -> CBOR
fn from(value: PrivateKeyBase) -> CBOR
Source§impl From<PublicKeyBase> for CBOR
impl From<PublicKeyBase> for CBOR
Source§fn from(value: PublicKeyBase) -> CBOR
fn from(value: PublicKeyBase) -> CBOR
Source§impl From<SealedMessage> for CBOR
impl From<SealedMessage> for CBOR
Source§fn from(value: SealedMessage) -> CBOR
fn from(value: SealedMessage) -> CBOR
Source§impl From<SigningPrivateKey> for CBOR
impl From<SigningPrivateKey> for CBOR
Source§fn from(value: SigningPrivateKey) -> CBOR
fn from(value: SigningPrivateKey) -> CBOR
Source§impl From<SigningPublicKey> for CBOR
impl From<SigningPublicKey> for CBOR
Source§fn from(value: SigningPublicKey) -> CBOR
fn from(value: SigningPublicKey) -> CBOR
Source§impl From<SymmetricKey> for CBOR
impl From<SymmetricKey> for CBOR
Source§fn from(value: SymmetricKey) -> CBOR
fn from(value: SymmetricKey) -> CBOR
Source§impl TryFrom<CBOR> for ByteString
impl TryFrom<CBOR> for ByteString
Source§impl TryFrom<CBOR> for KnownValue
impl TryFrom<CBOR> for KnownValue
Source§impl TryFrom<CBOR> for PrivateKeyBase
impl TryFrom<CBOR> for PrivateKeyBase
Source§impl TryFrom<CBOR> for PublicKeyBase
impl TryFrom<CBOR> for PublicKeyBase
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CBOREncodable for T
impl<T> CBOREncodable for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more