pub enum CborValue<'a> {
Array(Vec<Cow<'a, Cbor>>),
Dict(BTreeMap<Cow<'a, Cbor>, Cow<'a, Cbor>>),
Undefined,
Null,
Bool(bool),
Number(Number<'a>),
Timestamp(Timestamp),
Str(Cow<'a, str>),
Bytes(Cow<'a, [u8]>),
Invalid,
Unknown,
}Expand description
Lifted navigation structure for a CborValue.
You can obtain this using Cbor::decode().
This will reference existing bytes as much as possible, but in some cases it
has to allocate, e.g. when some needed slices are not contiguous in the underlying
Cbor.
Variants
Array(Vec<Cow<'a, Cbor>>)
Dict(BTreeMap<Cow<'a, Cbor>, Cow<'a, Cbor>>)
Undefined
Null
Bool(bool)
Number(Number<'a>)
Timestamp(Timestamp)
Str(Cow<'a, str>)
Bytes(Cow<'a, [u8]>)
Invalid
Structural constraints for a tag are violated (like tag 0 on a number)
Unknown
Unknown tags are present, you may want to manually interpret the TaggedItem
Implementations
sourceimpl<'a> CborValue<'a>
impl<'a> CborValue<'a>
pub fn new(item: TaggedItem<'a>) -> Self
pub fn is_undefined(&self) -> bool
pub fn is_null(&self) -> bool
pub fn is_unknown(&self) -> bool
pub fn is_invalid(&self) -> bool
pub fn as_bool(&self) -> Option<bool>
pub fn as_number(&self) -> Option<&Number<'_>>
pub fn to_number(self) -> Option<Number<'a>>
pub fn as_timestamp(&self) -> Option<Timestamp>
pub fn as_str(&self) -> Option<&Cow<'_, str>>
pub fn to_str(self) -> Option<Cow<'a, str>>
pub fn as_bytes(&self) -> Option<&Cow<'_, [u8]>>
pub fn to_bytes(self) -> Option<Cow<'a, [u8]>>
pub fn as_array(&self) -> Option<&[Cow<'a, Cbor>]>
pub fn to_array(self) -> Option<Vec<Cow<'a, Cbor>>>
pub fn as_dict(&self) -> Option<&BTreeMap<Cow<'a, Cbor>, Cow<'a, Cbor>>>
pub fn to_dict(self) -> Option<BTreeMap<Cow<'a, Cbor>, Cow<'a, Cbor>>>
sourcepub fn make_static(self) -> CborValue<'static>
pub fn make_static(self) -> CborValue<'static>
Cut all ties to the underlying byte slice, which often implies allocations
Trait Implementations
sourceimpl<'a> PartialEq<CborValue<'a>> for CborValue<'a>
impl<'a> PartialEq<CborValue<'a>> for CborValue<'a>
impl<'a> StructuralPartialEq for CborValue<'a>
Auto Trait Implementations
impl<'a> RefUnwindSafe for CborValue<'a>
impl<'a> Send for CborValue<'a>
impl<'a> Sync for CborValue<'a>
impl<'a> Unpin for CborValue<'a>
impl<'a> UnwindSafe for CborValue<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more