Skip to main content

Value

Enum Value 

Source
pub enum Value {
    SimpleValue(SimpleValue),
    Unsigned(u64),
    Negative(u64),
    Float(Float),
    ByteString(Vec<u8>),
    TextString(String),
    Array(Vec<Value>),
    Map(BTreeMap<Value, Value>),
    Tag(u64, Box<Value>),
}
Expand description

A single CBOR data item.

Value covers all CBOR major types: integers, floats, byte and text strings, arrays, maps, tagged values, and simple values (null, booleans). It encodes deterministically and decodes only canonical input.

§Creating values

Rust primitives convert via From:

use cbor_core::Value;

let n = Value::from(42);
let s = Value::from("hello");
let b = Value::from(true);

For arrays and maps the array! and map! macros are convenient:

use cbor_core::{Value, array, map};

let a = array![1, 2, 3];
let m = map! { "x" => 10, "y" => 20 };

Arrays and maps can also be built from standard Rust collections. Slices, Vecs, fixed-size arrays, BTreeMaps, HashMaps, and slices of key-value pairs all convert automatically:

use cbor_core::Value;
use std::collections::HashMap;

// Array from a slice
let a = Value::array([1, 2, 3].as_slice());

// Map from a HashMap
let mut hm = HashMap::new();
hm.insert(1, 2);
let m = Value::map(&hm);

// Map from key-value pairs
let m = Value::map([("x", 10), ("y", 20)]);

Use () to create empty arrays or maps without spelling out a type:

use cbor_core::Value;

let empty_array = Value::array(());
let empty_map = Value::map(());

assert_eq!(empty_array.as_array().unwrap().len(), 0);
assert_eq!(empty_map.as_map().unwrap().len(), 0);

Named constructors are available for cases where From is ambiguous:

ConstructorBuilds
Value::null()Null simple value
Value::simple_value(v)Arbitrary simple value
Value::float(v)Float in shortest CBOR form
Value::array(v)Array from slice, Vec, or fixed-size array
Value::map(v)Map from BTreeMap, HashMap, slice of pairs, etc.
Value::tag(n, v)Tagged value

§Encoding and decoding

use cbor_core::Value;

let original = Value::from(-1000);
let bytes = original.encode();
let decoded = Value::decode(&bytes).unwrap();
assert_eq!(original, decoded);

For streaming use, write_to and read_from operate on any io::Write / io::Read.

§Accessors

Accessor methods extract or borrow the inner data of each variant. All return Result<T>, yielding Err(Error::IncompatibleType) on a type mismatch. The naming follows Rust conventions:

PrefixMeaningReturns
as_*Borrow inner data&T or &mut T (with _mut)
to_*Convert or narrowOwned Copy type (u8, f32, …)
into_*Consume self, extractOwned T
no prefixTrivial propertyCopy scalar

§Simple values

In CBOR, booleans and null are not distinct types but specific simple values: false is 20, true is 21, null is 22. This means a boolean value is always also a simple value. to_bool provides typed access to true/false, while to_simple_value works on any simple value including booleans and null.

MethodReturnsNotes
to_simple_valueResult<u8>Raw simple value number
to_boolResult<bool>Only for true/false
use cbor_core::Value;

let v = Value::from(true);
assert_eq!(v.to_bool().unwrap(), true);
assert_eq!(v.to_simple_value().unwrap(), 21); // CBOR true = simple(21)

// null is also a simple value
let n = Value::null();
assert!(n.to_bool().is_err());              // not a boolean
assert_eq!(n.to_simple_value().unwrap(), 22); // but is simple(22)

§Integers

CBOR has effectively four integer types (unsigned or negative, and normal or big integer) with different internal representations. This is handled transparently by the API.

The to_* accessors perform checked narrowing into any Rust integer type, returning Err(Overflow) if the value does not fit, or Err(NegativeUnsigned) when extracting a negative value into an unsigned type.

MethodReturns
to_u8 .. to_u128, to_usizeResult<uN>
to_i8 .. to_i128, to_isizeResult<iN>
use cbor_core::Value;

let v = Value::from(1000);
assert_eq!(v.to_u32().unwrap(), 1000);
assert_eq!(v.to_i64().unwrap(), 1000);
assert!(v.to_u8().is_err()); // overflow

let neg = Value::from(-5);
assert_eq!(neg.to_i8().unwrap(), -5);
assert!(neg.to_u32().is_err()); // negative unsigned

§Floats

Floats are stored internally in their shortest CBOR encoding (f16, f32, or f64). to_f64 always succeeds since every float can widen to f64. to_f32 fails with Err(Precision) if the value is stored as f64. A float internally stored as f16 can always be converted to either an f32 or f64 for obvious reasons.

MethodReturns
to_f32Result<f32> (fails for f64 values)
to_f64Result<f64>
use cbor_core::Value;

let v = Value::from(2.5);
assert_eq!(v.to_f64().unwrap(), 2.5);
assert_eq!(v.to_f32().unwrap(), 2.5);

§Byte strings

Byte strings are stored as Vec<u8>. Use as_bytes for a borrowed slice, or into_bytes to take ownership without copying.

MethodReturns
as_bytesResult<&[u8]>
as_bytes_mutResult<&mut Vec<u8>>
into_bytesResult<Vec<u8>>
use cbor_core::Value;

let mut v = Value::from(vec![1, 2, 3]);
v.as_bytes_mut().unwrap().push(4);
assert_eq!(v.as_bytes().unwrap(), &[1, 2, 3, 4]);

§Text strings

Text strings are stored as String (guaranteed valid UTF-8 by the decoder). Use as_str for a borrowed &str, or into_string to take ownership.

MethodReturns
as_strResult<&str>
as_string_mutResult<&mut String>
into_stringResult<String>
use cbor_core::Value;

let v = Value::from("hello");
assert_eq!(v.as_str().unwrap(), "hello");

// Modify in place
let mut v = Value::from("hello");
v.as_string_mut().unwrap().push_str(" world");
assert_eq!(v.as_str().unwrap(), "hello world");

§Arrays

Arrays are stored as Vec<Value>. Use as_array to borrow the elements as a slice, or as_array_mut to modify them in place.

MethodReturns
as_arrayResult<&[Value]>
as_array_mutResult<&mut Vec<Value>>
into_arrayResult<Vec<Value>>
use cbor_core::{Value, array};

let v = array![10, 20, 30];
let items = v.as_array().unwrap();
assert_eq!(items[1].to_u32().unwrap(), 20);

// Modify in place
let mut v = array![1, 2];
v.as_array_mut().unwrap().push(3.into());
assert_eq!(v.as_array().unwrap().len(), 3);

§Maps

Maps are stored as BTreeMap<Value, Value>, giving canonical key order. Use standard BTreeMap methods on the result of as_map to look up entries.

MethodReturns
as_mapResult<&BTreeMap<Value, Value>>
as_map_mutResult<&mut BTreeMap<Value, Value>>
into_mapResult<BTreeMap<Value, Value>>
use cbor_core::{Value, map};

let v = map! { "name" => "Alice", "age" => 30 };
assert_eq!(v["name"].as_str().unwrap(), "Alice");

// Modify in place
let mut v = map! { "count" => 1 };
v.as_map_mut().unwrap().insert("count".into(), 2.into());
assert_eq!(v["count"].to_u32().unwrap(), 2);

§Indexing

Arrays and maps support Index and IndexMut with any type that converts into Value. For arrays the index is converted to usize; for maps it is used as a key lookup. Panics on type mismatch or missing key, just like Vec and BTreeMap.

use cbor_core::{Value, array, map};

let a = array![10, 20, 30];
assert_eq!(a[1].to_u32().unwrap(), 20);

let m = map! { "x" => 10, "y" => 20 };
assert_eq!(m["x"].to_u32().unwrap(), 10);

§Tags

A tag wraps another value with a numeric label (e.g. tag 1 for epoch timestamps, tag 32 for URIs). Tags can be nested.

MethodReturnsNotes
tag_numberResult<u64>Tag number
tag_contentResult<&Value>Borrowed content
tag_content_mutResult<&mut Value>Mutable content
as_tagResult<(u64, &Value)>Both parts
as_tag_mutResult<(u64, &mut Value)>Mutable content
into_tagResult<(u64, Value)>Consuming

Use untagged to look through tags without removing them, remove_tag to strip the outermost tag, or remove_all_tags to strip all layers at once.

use cbor_core::Value;

// Create a tagged value (tag 32 = URI)
let mut uri = Value::tag(32, "https://example.com");

// Inspect
let (tag_num, content) = uri.as_tag().unwrap();
assert_eq!(tag_num, 32);
assert_eq!(content.as_str().unwrap(), "https://example.com");

// Look through tags without removing them
assert_eq!(uri.untagged().as_str().unwrap(), "https://example.com");

// Strip the tag in place
let removed = uri.remove_tag();
assert_eq!(removed, Some(32));
assert_eq!(uri.as_str().unwrap(), "https://example.com");

Accessor methods see through tags transparently: calling as_str() on a tagged text string works without manually unwrapping the tag first. This applies to all accessors (to_*, as_*, into_*).

use cbor_core::Value;

let uri = Value::tag(32, "https://example.com");
assert_eq!(uri.as_str().unwrap(), "https://example.com");

// Nested tags are also transparent
let nested = Value::tag(100, Value::tag(200, 42));
assert_eq!(nested.to_u32().unwrap(), 42);

Big integers are internally represented as tagged byte strings (tags 2 and 3). The integer accessors recognise these tags and decode the bytes automatically, even when wrapped in additional custom tags. Byte-level accessors like as_bytes() also see through tags, so calling as_bytes() on a big integer returns the raw payload bytes.

If a tag is removed via remove_tag, remove_all_tags, or by consuming through into_tag, the value becomes a plain byte string and can no longer be read as an integer.

§Type introspection

data_type returns a DataType enum for lightweight type checks without matching on the full enum.

use cbor_core::Value;

let v = Value::from(3.14);
assert!(v.data_type().is_float());

Variants§

§

SimpleValue(SimpleValue)

Simple value such as null, true, or false (major type 7).

In CBOR, booleans and null are simple values, not distinct types. A Value::from(true) is stored as SimpleValue(21) and is accessible through both to_bool and to_simple_value.

§

Unsigned(u64)

Unsigned integer (major type 0). Stores values 0 through 2^64-1.

§

Negative(u64)

Negative integer (major type 1). The actual value is -1 - n, covering -1 through -2^64.

§

Float(Float)

IEEE 754 floating-point number (major type 7, additional info 25-27).

§

ByteString(Vec<u8>)

Byte string (major type 2).

§

TextString(String)

UTF-8 text string (major type 3).

§

Array(Vec<Value>)

Array of data items (major type 4).

§

Map(BTreeMap<Value, Value>)

Map of key-value pairs in canonical order (major type 5).

§

Tag(u64, Box<Value>)

Tagged data item (major type 6). The first field is the tag number, the second is the enclosed content.

Implementations§

Source§

impl Value

Source

pub fn to_f16(&self) -> Result<f16>

Available on crate feature half only.

Convert to half::f16.

Returns Err(Precision) for f32 or f64-width values.

Source§

impl Value

Source

pub fn take(&mut self) -> Self

Take the value out, leaving null in its place.

use cbor_core::Value;

let mut v = Value::from(42);
let taken = v.take();
assert_eq!(taken.to_u32().unwrap(), 42);
assert!(v.data_type().is_null());
Source

pub fn replace(&mut self, value: Self) -> Self

Replace the value, returning the old one.

use cbor_core::Value;

let mut v = Value::from("hello");
let old = v.replace(Value::from("world"));
assert_eq!(old.as_str().unwrap(), "hello");
assert_eq!(v.as_str().unwrap(), "world");
Source

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

Encode this value to binary CBOR bytes.

This is a convenience wrapper around write_to.

use cbor_core::Value;
let bytes = Value::from(42).encode();
assert_eq!(bytes, [0x18, 42]);
Source

pub fn encode_hex(&self) -> String

Encode this value to a hex-encoded CBOR string.

This is a convenience wrapper around write_hex_to.

use cbor_core::Value;
let hex = Value::from(42).encode_hex();
assert_eq!(hex, "182a");
Source

pub fn decode(bytes: impl AsRef<[u8]>) -> Result<Self>

Decode a CBOR data item from binary bytes.

Accepts any byte source (&[u8], &str, String, Vec<u8>, etc.). Returns Err if the encoding is not canonical.

This is a convenience wrapper around read_from.

use cbor_core::Value;
let v = Value::decode([0x18, 42]).unwrap();
assert_eq!(v.to_u32().unwrap(), 42);
Source

pub fn decode_hex(hex: impl AsRef<[u8]>) -> Result<Self>

Decode a CBOR data item from hex-encoded bytes.

Accepts any byte source (&[u8], &str, String, Vec<u8>, etc.). Both uppercase and lowercase hex digits are accepted. Returns Err if the encoding is not canonical.

This is a convenience wrapper around read_hex_from.

use cbor_core::Value;
let v = Value::decode_hex("182a").unwrap();
assert_eq!(v.to_u32().unwrap(), 42);
Source

pub fn read_from(reader: impl Read) -> IoResult<Self>

Read a single CBOR data item from a binary stream.

use cbor_core::Value;
let mut bytes: &[u8] = &[0x18, 42];
let v = Value::read_from(&mut bytes).unwrap();
assert_eq!(v.to_u32().unwrap(), 42);
Source

pub fn read_hex_from(reader: impl Read) -> IoResult<Self>

Read a single CBOR data item from a hex-encoded stream.

Each byte of CBOR is expected as two hex digits (uppercase or lowercase).

use cbor_core::Value;
let mut hex = "182a".as_bytes();
let v = Value::read_hex_from(&mut hex).unwrap();
assert_eq!(v.to_u32().unwrap(), 42);
Source

pub fn write_to(&self, writer: impl Write) -> IoResult<()>

Write this value as binary CBOR to a stream.

use cbor_core::Value;
let mut buf = Vec::new();
Value::from(42).write_to(&mut buf).unwrap();
assert_eq!(buf, [0x18, 42]);
Source

pub fn write_hex_to(&self, writer: impl Write) -> IoResult<()>

Write this value as hex-encoded CBOR to a stream.

Each binary byte is written as two lowercase hex digits. The adapter encodes on the fly without buffering the full output.

use cbor_core::Value;
let mut buf = Vec::new();
Value::from(42).write_hex_to(&mut buf).unwrap();
assert_eq!(buf, b"182a");
Source

pub const fn null() -> Self

Create a CBOR null value.

Source

pub fn simple_value(value: impl TryInto<SimpleValue>) -> Self

Create a CBOR simple value.

§Panics

Panics if the value is in the reserved range 24-31. Use SimpleValue::from_u8 for a fallible alternative.

Source

pub fn date_time(value: impl TryInto<DateTime>) -> Self

Create a CBOR date/time string value (tag 0).

Accepts &str, String, and SystemTime via the DateTime helper. The date must be within 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z.

§Panics

Panics if the input is not a valid RFC 3339 (ISO 8601 profile) UTC timestamp or is out of range.

use cbor_core::{DataType, Value};

let v = Value::date_time("2000-01-01T00:00:00.000Z");
assert_eq!(v.data_type(), DataType::DateTime);
assert_eq!(v.as_str(), Ok("2000-01-01T00:00:00.000Z"));

use std::time::SystemTime;
let v = Value::date_time(SystemTime::UNIX_EPOCH);
assert_eq!(v.data_type(), DataType::DateTime);
assert_eq!(v.as_str(), Ok("1970-01-01T00:00:00Z"));
Source

pub fn epoch_time(value: impl TryInto<EpochTime>) -> Self

Create a CBOR epoch time value (tag 1).

Accepts integers, floats, and SystemTime via the EpochTime helper. The value must be in the range 0 to 253402300799.

§Panics

Panics if the value is out of range or negative.

use std::time::{Duration, UNIX_EPOCH};
use cbor_core::Value;

let v = Value::epoch_time(1_000_000);
assert_eq!(v.to_system_time(), Ok(UNIX_EPOCH + Duration::from_secs(1_000_000)));
Source

pub fn float(value: impl Into<Float>) -> Self

Create a CBOR float.

Via the Float type floats can be created out of integers and booleans too.

use cbor_core::Value;

let f1 = Value::float(1.0);
assert!(f1.to_f64() == Ok(1.0));

let f2 = Value::float(2);
assert!(f2.to_f64() == Ok(2.0));

let f3 = Value::float(true);
assert!(f3.to_f64() == Ok(1.0));

The value is stored in the shortest IEEE 754 form (f16, f32, or f64) that preserves it exactly.

Source

pub fn array(array: impl Into<Array>) -> Self

Create a CBOR array.

Accepts any type that converts into Array, including Vec<T>, [T; N], &[T], and Box<[T]> where T: Into<Value>. See Array for the full list of accepted types.

let a = Value::array([1, 2, 3]);
assert_eq!(a.as_array().unwrap().len(), 3);
Source

pub fn map(map: impl Into<Map>) -> Self

Create a CBOR map. Keys are stored in canonical order.

Accepts any type that converts into Map, including BTreeMap, &HashMap, Vec<(K, V)>, [(K, V); N], and &[(K, V)]. See Map for the full list of accepted types.

let m = Value::map([("x", 1), ("y", 2)]);
assert_eq!(m.as_map().unwrap().len(), 2);
Source

pub fn tag(number: u64, content: impl Into<Value>) -> Self

Wrap a value with a CBOR tag.

use cbor_core::Value;
let uri = Value::tag(32, "https://example.com");
assert_eq!(uri.tag_number().unwrap(), 32);
Source

pub const fn data_type(&self) -> DataType

Return the DataType of this value for type-level dispatch.

Source

pub const fn to_bool(&self) -> Result<bool>

Extract a boolean. Returns Err for non-boolean values.

Source

pub const fn to_simple_value(&self) -> Result<u8>

Extract the raw simple value number (0-255, excluding 24-31).

Source

pub fn to_u8(&self) -> Result<u8>

Narrow to u8. Returns Err(Overflow) or Err(NegativeUnsigned) on mismatch.

Source

pub fn to_u16(&self) -> Result<u16>

Narrow to u16.

Source

pub fn to_u32(&self) -> Result<u32>

Narrow to u32.

Source

pub fn to_u64(&self) -> Result<u64>

Narrow to u64.

Source

pub fn to_u128(&self) -> Result<u128>

Narrow to u128. Handles big integers (tag 2) transparently.

Source

pub fn to_usize(&self) -> Result<usize>

Narrow to usize.

Source

pub fn to_i8(&self) -> Result<i8>

Narrow to i8.

Source

pub fn to_i16(&self) -> Result<i16>

Narrow to i16.

Source

pub fn to_i32(&self) -> Result<i32>

Narrow to i32.

Source

pub fn to_i64(&self) -> Result<i64>

Narrow to i64.

Source

pub fn to_i128(&self) -> Result<i128>

Narrow to i128. Handles big integers (tags 2 and 3) transparently.

Source

pub fn to_isize(&self) -> Result<isize>

Narrow to isize.

Source

pub fn to_f32(&self) -> Result<f32>

Convert to f32.

Returns Err(Precision) for f64-width values.

Source

pub fn to_f64(&self) -> Result<f64>

Convert to f64.

Always succeeds for float values.

Source

pub fn to_system_time(&self) -> Result<SystemTime>

Convert a time value to SystemTime.

Accepts date/time strings (tag 0), epoch time values (tag 1), and untagged integers or floats. Numeric values must be non-negative and in the range 0 to 253402300799. Date/time strings may include a timezone offset, which is converted to UTC.

Returns Err(IncompatibleType) for values that are neither numeric nor text, Err(InvalidValue) if a numeric value is out of range, and Err(InvalidFormat) if a text string is not a valid RFC 3339 timestamp. Leap seconds (:60) are rejected because SystemTime cannot represent them.

use std::time::{Duration, UNIX_EPOCH};
use cbor_core::Value;

let v = Value::tag(1, 1_000_000);
let t = v.to_system_time().unwrap();
assert_eq!(t, UNIX_EPOCH + Duration::from_secs(1_000_000));
Source

pub fn as_bytes(&self) -> Result<&[u8]>

Borrow the byte string as a slice.

Source

pub const fn as_bytes_mut(&mut self) -> Result<&mut Vec<u8>>

Borrow the byte string as a mutable Vec.

Source

pub fn into_bytes(self) -> Result<Vec<u8>>

Take ownership of the byte string.

Source

pub fn as_str(&self) -> Result<&str>

Borrow the text string as a &str.

Source

pub const fn as_string_mut(&mut self) -> Result<&mut String>

Borrow the text string as a mutable String.

Source

pub fn into_string(self) -> Result<String>

Take ownership of the text string.

Source

pub fn as_array(&self) -> Result<&[Value]>

Borrow the array elements as a slice.

Source

pub const fn as_array_mut(&mut self) -> Result<&mut Vec<Value>>

Borrow the array as a mutable Vec.

Source

pub fn into_array(self) -> Result<Vec<Value>>

Take ownership of the array.

Source

pub const fn as_map(&self) -> Result<&BTreeMap<Value, Value>>

Borrow the map.

Source

pub const fn as_map_mut(&mut self) -> Result<&mut BTreeMap<Value, Value>>

Borrow the map mutably.

Source

pub fn into_map(self) -> Result<BTreeMap<Value, Value>>

Take ownership of the map.

Source

pub fn get(&self, index: impl Into<Value>) -> Option<&Value>

Look up an element by index (arrays) or key (maps).

Returns None if the value is not an array or map, the index is out of bounds, or the key is missing.

use cbor_core::{Value, array, map};

let a = array![10, 20, 30];
assert_eq!(a.get(1).unwrap().to_u32().unwrap(), 20);
assert!(a.get(5).is_none());

let m = map! { "x" => 10 };
assert_eq!(m.get("x").unwrap().to_u32().unwrap(), 10);
assert!(m.get("missing").is_none());
Source

pub fn get_mut(&mut self, index: impl Into<Value>) -> Option<&mut Value>

Mutable version of get.

use cbor_core::{Value, array};

let mut a = array![10, 20, 30];
*a.get_mut(1).unwrap() = Value::from(99);
assert_eq!(a[1].to_u32().unwrap(), 99);
Source

pub const fn tag_number(&self) -> Result<u64>

Return the tag number.

Source

pub const fn tag_content(&self) -> Result<&Self>

Borrow the tag content.

Source

pub const fn tag_content_mut(&mut self) -> Result<&mut Self>

Mutably borrow the tag content.

Source

pub fn as_tag(&self) -> Result<(u64, &Value)>

Borrow tag number and content together.

Source

pub fn as_tag_mut(&mut self) -> Result<(u64, &mut Value)>

Borrow tag number and mutable content together.

Source

pub fn into_tag(self) -> Result<(u64, Value)>

Consume self and return tag number and content.

Source

pub fn remove_tag(&mut self) -> Option<u64>

Remove the outermost tag, returning its number. Returns None if the value is not tagged.

Source

pub fn remove_all_tags(&mut self) -> Vec<u64>

Remove all nested tags, returning their numbers from outermost to innermost.

Source

pub const fn untagged(&self) -> &Self

Borrow the innermost non-tag value, skipping all tag wrappers.

Source

pub const fn untagged_mut(&mut self) -> &mut Self

Mutable version of untagged.

Source

pub fn into_untagged(self) -> Self

Consuming version of untagged.

Trait Implementations§

Source§

impl Clone for Value

Source§

fn clone(&self) -> Value

Returns a duplicate 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 Value

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Value

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Value

Available on crate feature serde only.
Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<&[u8]> for Value

Source§

fn from(value: &[u8]) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize> From<&[u8; N]> for Value

Source§

fn from(value: &[u8; N]) -> Self

Converts to this type from the input type.
Source§

impl From<&BigInt> for Value

Available on crate feature num-bigint only.
Source§

fn from(value: &BigInt) -> Self

Encodes a BigInt as a CBOR integer.

Source§

impl From<&BigUint> for Value

Available on crate feature num-bigint only.
Source§

fn from(value: &BigUint) -> Self

Encodes a BigUint as a CBOR integer.

Values that fit in a u64 are encoded as a plain unsigned integer. Larger values are encoded as a tag-2 big integer

Source§

impl<const LIMBS: usize> From<&Int<LIMBS>> for Value
where Uint<LIMBS>: Encoding,

Available on crate feature crypto-bigint only.
Source§

fn from(value: &Int<LIMBS>) -> Self

Converts to this type from the input type.
Source§

impl From<&Integer> for Value

Available on crate feature rug only.
Source§

fn from(value: &Integer) -> Self

Converts to this type from the input type.
Source§

impl<const LIMBS: usize> From<&NonZero<Int<LIMBS>>> for Value
where Uint<LIMBS>: Encoding,

Available on crate feature crypto-bigint only.
Source§

fn from(value: &NonZero<Int<LIMBS>>) -> Self

Converts to this type from the input type.
Source§

impl<const LIMBS: usize> From<&NonZero<Uint<LIMBS>>> for Value
where Uint<LIMBS>: Encoding,

Available on crate feature crypto-bigint only.
Source§

fn from(value: &NonZero<Uint<LIMBS>>) -> Self

Converts to this type from the input type.
Source§

impl From<&String> for Value

Source§

fn from(value: &String) -> Self

Converts to this type from the input type.
Source§

impl<const LIMBS: usize> From<&Uint<LIMBS>> for Value
where Uint<LIMBS>: Encoding,

Available on crate feature crypto-bigint only.
Source§

fn from(value: &Uint<LIMBS>) -> Self

Converts to this type from the input type.
Source§

impl From<&str> for Value

Source§

fn from(value: &str) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize> From<[Value; N]> for Value

Source§

fn from(value: [Value; N]) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize> From<[u8; N]> for Value

Source§

fn from(value: [u8; N]) -> Self

Converts to this type from the input type.
Source§

impl From<Array> for Value

Source§

fn from(value: Array) -> Self

Converts to this type from the input type.
Source§

impl From<BTreeMap<Value, Value>> for Value

Source§

fn from(value: BTreeMap<Value, Value>) -> Self

Converts to this type from the input type.
Source§

impl From<BigInt> for Value

Available on crate feature num-bigint only.
Source§

fn from(value: BigInt) -> Self

Encodes a BigInt as a CBOR integer.

Source§

impl From<BigUint> for Value

Available on crate feature num-bigint only.
Source§

fn from(value: BigUint) -> Self

Encodes a BigUint as a CBOR integer.

Values that fit in a u64 are encoded as a plain unsigned integer. Larger values are encoded as a tag-2 big integer

Source§

impl From<Box<[Value]>> for Value

Source§

fn from(value: Box<[Value]>) -> Self

Converts to this type from the input type.
Source§

impl From<Box<[u8]>> for Value

Source§

fn from(value: Box<[u8]>) -> Self

Converts to this type from the input type.
Source§

impl From<Box<str>> for Value

Source§

fn from(value: Box<str>) -> Self

Converts to this type from the input type.
Source§

impl From<DateTime> for Value

Source§

fn from(value: DateTime) -> Self

Converts to this type from the input type.
Source§

impl From<EpochTime> for Value

Source§

fn from(value: EpochTime) -> Self

Converts to this type from the input type.
Source§

impl From<Float> for Value

Source§

fn from(value: Float) -> Self

Converts to this type from the input type.
Source§

impl<const LIMBS: usize> From<Int<LIMBS>> for Value
where Uint<LIMBS>: Encoding,

Available on crate feature crypto-bigint only.
Source§

fn from(value: Int<LIMBS>) -> Self

Encodes a crypto_bigint::Int as a CBOR integer.

Source§

impl From<Integer> for Value

Available on crate feature rug only.
Source§

fn from(value: Integer) -> Self

Encodes a rug::Integer as a CBOR integer.

Values that fit in a u64/i64 are encoded as plain integers. Larger values are encoded as tag-2/tag-3 big integers.

Source§

impl From<Map> for Value

Source§

fn from(value: Map) -> Self

Converts to this type from the input type.
Source§

impl<const LIMBS: usize> From<NonZero<Int<LIMBS>>> for Value
where Uint<LIMBS>: Encoding,

Available on crate feature crypto-bigint only.
Source§

fn from(value: NonZero<Int<LIMBS>>) -> Self

Converts to this type from the input type.
Source§

impl<const LIMBS: usize> From<NonZero<Uint<LIMBS>>> for Value
where Uint<LIMBS>: Encoding,

Available on crate feature crypto-bigint only.
Source§

fn from(value: NonZero<Uint<LIMBS>>) -> Self

Converts to this type from the input type.
Source§

impl From<SimpleValue> for Value

Source§

fn from(value: SimpleValue) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Value

Source§

fn from(value: String) -> Self

Converts to this type from the input type.
Source§

impl<const LIMBS: usize> From<Uint<LIMBS>> for Value
where Uint<LIMBS>: Encoding,

Available on crate feature crypto-bigint only.
Source§

fn from(value: Uint<LIMBS>) -> Self

Encodes a crypto_bigint::Uint as a CBOR integer.

Values that fit in a u64 are encoded as a plain unsigned integer. Larger values are encoded as a tag-2 big integer.

Source§

impl From<Vec<Value>> for Value

Source§

fn from(value: Vec<Value>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<u8>> for Value

Source§

fn from(value: Vec<u8>) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for Value

Source§

fn from(value: bool) -> Self

Converts to this type from the input type.
Source§

impl From<f16> for Value

Available on crate feature half only.
Source§

fn from(value: f16) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for Value

Source§

fn from(value: f32) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for Value

Source§

fn from(value: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i128> for Value

Source§

fn from(value: i128) -> Self

Converts to this type from the input type.
Source§

impl From<i16> for Value

Source§

fn from(value: i16) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for Value

Source§

fn from(value: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for Value

Source§

fn from(value: i64) -> Self

Converts to this type from the input type.
Source§

impl From<i8> for Value

Source§

fn from(value: i8) -> Self

Converts to this type from the input type.
Source§

impl From<isize> for Value

Available on 32-bit or 64-bit only.
Source§

fn from(value: isize) -> Self

Converts to this type from the input type.
Source§

impl From<u128> for Value

Source§

fn from(value: u128) -> Self

Converts to this type from the input type.
Source§

impl From<u16> for Value

Source§

fn from(value: u16) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for Value

Source§

fn from(value: u32) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for Value

Source§

fn from(value: u64) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for Value

Source§

fn from(value: u8) -> Self

Converts to this type from the input type.
Source§

impl From<usize> for Value

Available on 32-bit or 64-bit only.
Source§

fn from(value: usize) -> Self

Converts to this type from the input type.
Source§

impl Hash for Value

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<I: Into<Value>> Index<I> for Value

Source§

type Output = Value

The returned type after indexing.
Source§

fn index(&self, index: I) -> &Value

Performs the indexing (container[index]) operation. Read more
Source§

impl<I: Into<Value>> IndexMut<I> for Value

Source§

fn index_mut(&mut self, index: I) -> &mut Value

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl Ord for Value

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Value

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Value

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for Value

Available on crate feature serde only.
Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl<'a> TryFrom<&'a Value> for &'a [Value]

Source§

type Error = Error

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

fn try_from(value: &'a Value) -> Result<Self>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a Value> for &'a [u8]

Source§

type Error = Error

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

fn try_from(value: &'a Value) -> Result<Self>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a Value> for &'a BTreeMap<Value, Value>

Source§

type Error = Error

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

fn try_from(value: &'a Value) -> Result<Self>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a Value> for &'a str

Source§

type Error = Error

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

fn try_from(value: &'a Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<&Value> for BigInt

Available on crate feature num-bigint only.
Source§

fn try_from(value: &Value) -> Result<Self>

Extracts a BigInt from a CBOR integer value.

Returns Err(IncompatibleType) for non-integer values.

Source§

type Error = Error

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

impl TryFrom<&Value> for BigUint

Available on crate feature num-bigint only.
Source§

fn try_from(value: &Value) -> Result<Self>

Extracts a BigUint from a CBOR integer value.

Returns Err(NegativeUnsigned) for negative integers, Err(IncompatibleType) for non-integer values.

Source§

type Error = Error

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

impl TryFrom<&Value> for DateTime<FixedOffset>

Available on crate feature chrono only.
Source§

type Error = Error

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

fn try_from(value: &Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<&Value> for DateTime<Utc>

Available on crate feature chrono only.
Source§

type Error = Error

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

fn try_from(value: &Value) -> Result<Self>

Performs the conversion.
Source§

impl<const LIMBS: usize> TryFrom<&Value> for Int<LIMBS>
where Uint<LIMBS>: Encoding,

Available on crate feature crypto-bigint only.
Source§

type Error = Error

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

fn try_from(value: &Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<&Value> for Integer

Available on crate feature rug only.
Source§

type Error = Error

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

fn try_from(value: &Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<&Value> for OffsetDateTime

Available on crate feature time only.
Source§

type Error = Error

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

fn try_from(value: &Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<&Value> for SimpleValue

Source§

type Error = Error

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

fn try_from(value: &Value) -> Result<Self>

Performs the conversion.
Source§

impl<const LIMBS: usize> TryFrom<&Value> for Uint<LIMBS>
where Uint<LIMBS>: Encoding,

Available on crate feature crypto-bigint only.
Source§

type Error = Error

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

fn try_from(value: &Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<&Value> for UtcDateTime

Available on crate feature time only.
Source§

type Error = Error

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

fn try_from(value: &Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<&Value> for bool

Source§

type Error = Error

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

fn try_from(value: &Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<&Value> for f32

Source§

type Error = Error

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

fn try_from(value: &Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<&Value> for f64

Source§

type Error = Error

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

fn try_from(value: &Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<&Value> for i128

Source§

type Error = Error

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

fn try_from(value: &Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<&Value> for i16

Source§

type Error = Error

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

fn try_from(value: &Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<&Value> for i32

Source§

type Error = Error

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

fn try_from(value: &Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<&Value> for i64

Source§

type Error = Error

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

fn try_from(value: &Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<&Value> for i8

Source§

type Error = Error

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

fn try_from(value: &Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<&Value> for isize

Source§

type Error = Error

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

fn try_from(value: &Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<&Value> for u128

Source§

type Error = Error

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

fn try_from(value: &Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<&Value> for u16

Source§

type Error = Error

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

fn try_from(value: &Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<&Value> for u32

Source§

type Error = Error

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

fn try_from(value: &Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<&Value> for u64

Source§

type Error = Error

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

fn try_from(value: &Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<&Value> for u8

Source§

type Error = Error

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

fn try_from(value: &Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<&Value> for usize

Source§

type Error = Error

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

fn try_from(value: &Value) -> Result<Self>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a mut Value> for &'a mut BTreeMap<Value, Value>

Source§

type Error = Error

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

fn try_from(value: &'a mut Value) -> Result<Self>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a mut Value> for &'a mut String

Source§

type Error = Error

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

fn try_from(value: &'a mut Value) -> Result<Self>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a mut Value> for &'a mut Vec<Value>

Source§

type Error = Error

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

fn try_from(value: &'a mut Value) -> Result<Self>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a mut Value> for &'a mut Vec<u8>

Source§

type Error = Error

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

fn try_from(value: &'a mut Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Value> for Array

Source§

type Error = Error

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

fn try_from(value: Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Value> for BTreeMap<Value, Value>

Source§

type Error = Error

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

fn try_from(value: Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Value> for BigInt

Available on crate feature num-bigint only.
Source§

fn try_from(value: Value) -> Result<Self>

Extracts a BigInt from a CBOR integer value.

Returns Err(IncompatibleType) for non-integer values.

Source§

type Error = Error

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

impl TryFrom<Value> for BigUint

Available on crate feature num-bigint only.
Source§

fn try_from(value: Value) -> Result<Self>

Extracts a BigUint from a CBOR integer value.

Returns Err(NegativeUnsigned) for negative integers, Err(IncompatibleType) for non-integer values.

Source§

type Error = Error

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

impl TryFrom<Value> for DateTime<FixedOffset>

Available on crate feature chrono only.
Source§

fn try_from(value: Value) -> Result<Self>

Extracts a chrono::DateTime<FixedOffset> from a CBOR time value.

Date/time strings (tag 0) preserve the original timezone offset. Epoch integers/floats are returned with a UTC offset.

Source§

type Error = Error

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

impl TryFrom<Value> for DateTime<Utc>

Available on crate feature chrono only.
Source§

fn try_from(value: Value) -> Result<Self>

Extracts a chrono::DateTime<Utc> from a CBOR time value.

Accepts date/time strings (tag 0), epoch integers/floats (tag 1), and untagged integers, floats, or text strings.

Source§

type Error = Error

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

impl TryFrom<Value> for Float

Source§

type Error = Error

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

fn try_from(value: Value) -> Result<Self>

Performs the conversion.
Source§

impl<const LIMBS: usize> TryFrom<Value> for Int<LIMBS>
where Uint<LIMBS>: Encoding,

Available on crate feature crypto-bigint only.
Source§

fn try_from(value: Value) -> Result<Self>

Extracts a crypto_bigint::Int from a CBOR integer value.

Returns Err(Overflow) if the value does not fit, Err(IncompatibleType) for non-integer values.

Source§

type Error = Error

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

impl TryFrom<Value> for Integer

Available on crate feature rug only.
Source§

fn try_from(value: Value) -> Result<Self>

Extracts a rug::Integer from a CBOR integer value.

Returns Err(IncompatibleType) for non-integer values.

Source§

type Error = Error

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

impl TryFrom<Value> for Map

Source§

type Error = Error

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

fn try_from(value: Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Value> for OffsetDateTime

Available on crate feature time only.
Source§

fn try_from(value: Value) -> Result<Self>

Extracts a time::OffsetDateTime from a CBOR time value.

Date/time strings (tag 0) preserve the original timezone offset. Epoch integers/floats are returned with a UTC offset.

Source§

type Error = Error

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

impl TryFrom<Value> for SimpleValue

Source§

type Error = Error

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

fn try_from(value: Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Value> for String

Source§

type Error = Error

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

fn try_from(value: Value) -> Result<Self>

Performs the conversion.
Source§

impl<const LIMBS: usize> TryFrom<Value> for Uint<LIMBS>
where Uint<LIMBS>: Encoding,

Available on crate feature crypto-bigint only.
Source§

fn try_from(value: Value) -> Result<Self>

Extracts a crypto_bigint::Uint from a CBOR integer value.

Returns Err(NegativeUnsigned) for negative integers, Err(Overflow) if the value does not fit, Err(IncompatibleType) for non-integer values.

Source§

type Error = Error

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

impl TryFrom<Value> for UtcDateTime

Available on crate feature time only.
Source§

fn try_from(value: Value) -> Result<Self>

Extracts a time::UtcDateTime from a CBOR time value.

Date/time strings (tag 0) preserve the original timezone offset. Epoch integers/floats are returned with a UTC offset.

Source§

type Error = Error

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

impl TryFrom<Value> for Vec<Value>

Source§

type Error = Error

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

fn try_from(value: Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Value> for Vec<u8>

Source§

type Error = Error

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

fn try_from(value: Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Value> for bool

Source§

type Error = Error

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

fn try_from(value: Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Value> for f16

Available on crate feature half only.
Source§

type Error = Error

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

fn try_from(value: Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Value> for f32

Source§

type Error = Error

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

fn try_from(value: Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Value> for f64

Source§

type Error = Error

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

fn try_from(value: Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Value> for i128

Source§

type Error = Error

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

fn try_from(value: Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Value> for i16

Source§

type Error = Error

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

fn try_from(value: Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Value> for i32

Source§

type Error = Error

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

fn try_from(value: Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Value> for i64

Source§

type Error = Error

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

fn try_from(value: Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Value> for i8

Source§

type Error = Error

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

fn try_from(value: Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Value> for isize

Source§

type Error = Error

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

fn try_from(value: Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Value> for u128

Source§

type Error = Error

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

fn try_from(value: Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Value> for u16

Source§

type Error = Error

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

fn try_from(value: Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Value> for u32

Source§

type Error = Error

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

fn try_from(value: Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Value> for u64

Source§

type Error = Error

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

fn try_from(value: Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Value> for u8

Source§

type Error = Error

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

fn try_from(value: Value) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Value> for usize

Source§

type Error = Error

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

fn try_from(value: Value) -> Result<Self>

Performs the conversion.
Source§

impl Eq for Value

Auto Trait Implementations§

§

impl Freeze for Value

§

impl RefUnwindSafe for Value

§

impl Send for Value

§

impl Sync for Value

§

impl Unpin for Value

§

impl UnsafeUnpin for Value

§

impl UnwindSafe for Value

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> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> StrictAs for T

Source§

fn strict_as<Dst>(self) -> Dst
where T: StrictCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> StrictCastFrom<Src> for Dst
where Src: StrictCast<Dst>,

Source§

fn strict_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,