Struct cbor_data::CborValue [−][src]
Representation of a possibly tagged CBOR data item.
Fields
kind: ValueKind<'a>
bytes: &'a [u8]
Implementations
impl<'a> CborValue<'a>
[src]
pub fn decoded(&self) -> Option<Self>
[src]
Strip off wrappers of CBOR item encoding: sees through byte strings with
TAG_CBOR_ITEM
.
pub fn tags(&self) -> Tags<'a>ⓘ
[src]
Get value all tags, from the outermost to the innermost
pub fn as_bool(&self) -> Option<bool>
[src]
pub fn as_u64(&self) -> Option<u64>
[src]
Try to interpret this value as a 64bit unsigned integer.
Currently does not check floats or big integers.
pub fn as_i64(&self) -> Option<i64>
[src]
Try to interpret this value as a signed integer.
Currently does not check floats or big integers.
pub fn as_i32(&self) -> Option<i32>
[src]
Try to interpret this value as a signed integer.
Currently does not check floats or big integers.
pub fn as_f64(&self) -> Option<f64>
[src]
Try to interpret this value as a floating-point number.
TODO: add proper representations for the big number types supported by CBOR
pub fn as_bytes(&self) -> Option<Cow<'a, [u8]>>
[src]
Try to interpret this value as byte string.
This returns a Cow
because it may need to allocate a vector when decoding base64 strings.
pub fn as_str(&self) -> Option<&'a str>
[src]
Try to interpret this value as string.
Returns None if the type is not a (byte) string or the bytes are not valid UTF-8. base64 encoded strings (TAG_BASE64 or TAG_BASE64URL) are not decoded but returned as they are (even when their binary decoded form is valid UTF-8).
pub fn as_object(&self) -> Option<CborObject<'a>>
[src]
Lift a representation from this CBOR item that turns arrays into vectors and dicts into BTreeMaps.
This method is mostly useful for diagnostics and tests.
Trait Implementations
impl<'a> Clone for CborValue<'a>
[src]
impl<'a> Debug for CborValue<'a>
[src]
impl<'a> Display for CborValue<'a>
[src]
impl<'a> PartialEq<CborValue<'_>> for CborValue<'a>
[src]
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
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,