Enum oasis_cbor::Value
source · pub enum Value {
Unsigned(u64),
Negative(i128),
ByteString(Vec<u8, Global>),
TextString(String),
Array(Vec<Value, Global>),
Map(Vec<(Value, Value), Global>),
Tag(u64, Box<Value, Global>),
Simple(SimpleValue),
}
Expand description
Possible CBOR values.
Variants
Unsigned(u64)
Unsigned integer value (uint).
Negative(i128)
Signed integer value (nint). Only 63 bits of information are used here.
ByteString(Vec<u8, Global>)
Byte string (bstr).
TextString(String)
Text string (tstr).
Array(Vec<Value, Global>)
Array/tuple of values.
Map(Vec<(Value, Value), Global>)
Map of key-value pairs.
Tag(u64, Box<Value, Global>)
Tagged value.
Simple(SimpleValue)
Simple value.
Implementations
sourceimpl Value
impl Value
sourcepub fn integer(int: i64) -> Value
pub fn integer(int: i64) -> Value
Create an appropriate CBOR integer value (uint/nint). For simplicity, this only takes i64. Construct directly for the last bit.
sourcepub fn bool_value(b: bool) -> Value
pub fn bool_value(b: bool) -> Value
Create a CBOR boolean simple value.
sourcepub fn type_label(&self) -> u8
pub fn type_label(&self) -> u8
Return the major type for the Value
.
Trait Implementations
sourceimpl Decode for Value
impl Decode for Value
sourcefn try_default() -> Result<Self, DecodeError>
fn try_default() -> Result<Self, DecodeError>
Try to decode from a missing/null/undefined value.
sourcefn try_from_cbor_value(value: Value) -> Result<Self, DecodeError>
fn try_from_cbor_value(value: Value) -> Result<Self, DecodeError>
Try to decode from a given CBOR value.
sourcefn try_from_cbor_value_default(value: Value) -> Result<Self, DecodeError>where
Self: Sized,
fn try_from_cbor_value_default(value: Value) -> Result<Self, DecodeError>where
Self: Sized,
Try to decode from a given CBOR value, calling
try_default
in case the value is null or
undefined. Read moresourceimpl Ord for Value
impl Ord for Value
1.21.0 · sourcefn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialOrd<Value> for Value
impl PartialOrd<Value> for Value
sourcefn partial_cmp(&self, other: &Value) -> Option<Ordering>
fn partial_cmp(&self, other: &Value) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Eq for Value
Auto Trait Implementations
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnwindSafe for Value
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
sourceimpl<T> IntoCborValue for Twhere
Value: From<T>,
impl<T> IntoCborValue for Twhere
Value: From<T>,
sourcefn into_cbor_value(self) -> Value
fn into_cbor_value(self) -> Value
Convert
self
into a CBOR Value
, consuming it along the way.sourceimpl<T> IntoCborValueOption for Twhere
Value: From<T>,
impl<T> IntoCborValueOption for Twhere
Value: From<T>,
sourcefn into_cbor_value_option(self) -> Option<Value>
fn into_cbor_value_option(self) -> Option<Value>
Convert
self
into a CBOR Option<Value>
, consuming it along the way.