#[repr(u64)]pub enum Value {
Show 25 variants
U8(u8),
I8(i8),
U16(u16),
I16(i16),
U32(u32),
V32(u32),
I32(i32),
Z32(i32),
U64(u64),
V64(u64),
I64(i64),
Z64(i64),
F32(f32),
F64(f64),
Bool(bool),
Null = 32_768,
String(ArcStr),
Bytes(PBytes),
Error(Arc<Value>),
Array(ValArray),
Map(Map),
Decimal(Arc<Decimal>),
DateTime(Arc<DateTime<Utc>>),
Duration(Arc<Duration>),
Abstract(Abstract),
}Expand description
A dynamically-typed value that can be published and subscribed.
This type is divided into two subtypes: copy and clone. If the tag word is <= COPY_MAX then the type is copy, otherwise it must be cloned. Additionally, the tag word values are THE SAME as the values of the cases of Typ. Getting the Typ of a value is therefore a simply copy of the discriminant of Value.
It is essential that when adding variants you update COPY_MAX and Typ correctly. If adding a non copy type, you will also need to update the implementation of clone to match and delegate the clone operation.
Variants§
U8(u8)
unsigned byte
I8(i8)
signed byte
U16(u16)
u16
I16(i16)
i16
U32(u32)
full 4 byte u32
V32(u32)
LEB128 varint, 1 - 5 bytes depending on value
I32(i32)
full 4 byte i32
Z32(i32)
LEB128 varint zigzag encoded, 1 - 5 bytes depending on abs(value)
U64(u64)
full 8 byte u64
V64(u64)
LEB128 varint, 1 - 10 bytes depending on value
I64(i64)
full 8 byte i64
Z64(i64)
LEB128 varint zigzag encoded, 1 - 10 bytes depending on abs(value)
F32(f32)
4 byte ieee754 single precision float
F64(f64)
8 byte ieee754 double precision float
Bool(bool)
boolean true
Null = 32_768
Empty value
String(ArcStr)
unicode string
Bytes(PBytes)
byte array
Error(Arc<Value>)
An explicit error
Array(ValArray)
An array of values
Map(Map)
A Map of values
Decimal(Arc<Decimal>)
fixed point decimal type
DateTime(Arc<DateTime<Utc>>)
UTC timestamp
Duration(Arc<Duration>)
Duration
Abstract(Abstract)
Abstract
Implementations§
Source§impl Value
impl Value
pub fn approx_eq(&self, v: &Self) -> bool
Sourcepub fn discriminant(&self) -> u64
pub fn discriminant(&self) -> u64
return the discriminant tag of this value
Sourcepub fn is_copy(&self) -> bool
pub fn is_copy(&self) -> bool
return true if this value will be cloned by a direct bitwise copy
Sourcepub fn cast(self, typ: Typ) -> Option<Value>
pub fn cast(self, typ: Typ) -> Option<Value>
Whatever value is attempt to turn it into the type specified
Sourcepub fn cast_to<T: FromValue + Sized>(self) -> Result<T>
pub fn cast_to<T: FromValue + Sized>(self) -> Result<T>
cast value directly to any type implementing FromValue
Sourcepub fn get_as<T: FromValue + Sized>(self) -> Option<T>
pub fn get_as<T: FromValue + Sized>(self) -> Option<T>
get the value as T, return None if the value isn’t a T.
don’t attempt to cast.
Sourcepub fn downcast_ref<T: Any + Send + Sync>(&self) -> Option<&T>
pub fn downcast_ref<T: Any + Send + Sync>(&self) -> Option<&T>
downcast an abstract value to it’s concrete type
return None if the value isn’t abstract, or if T is not it’s
concrete type.
Sourcepub unsafe fn get_as_unchecked<T>(&self) -> &T
pub unsafe fn get_as_unchecked<T>(&self) -> &T
get a reference to the payload of the value without checking the tag
If you are wrong about what kind of value you have then this could cause undefined behavior.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Value
impl<'de> Deserialize<'de> for Value
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<T: Into<Value>, U: Into<Value>, V: Into<Value>, W: Into<Value>> From<(T, U, V, W)> for Value
impl<T: Into<Value>, U: Into<Value>, V: Into<Value>, W: Into<Value>> From<(T, U, V, W)> for Value
Source§fn from((t, u, v, w): (T, U, V, W)) -> Value
fn from((t, u, v, w): (T, U, V, W)) -> Value
Source§impl<T: Into<Value>, U: Into<Value>, V: Into<Value>, W: Into<Value>, X: Into<Value>> From<(T, U, V, W, X)> for Value
impl<T: Into<Value>, U: Into<Value>, V: Into<Value>, W: Into<Value>, X: Into<Value>> From<(T, U, V, W, X)> for Value
Source§fn from((t, u, v, w, x): (T, U, V, W, X)) -> Value
fn from((t, u, v, w, x): (T, U, V, W, X)) -> Value
Source§impl<T: Into<Value>, U: Into<Value>, V: Into<Value>, W: Into<Value>, X: Into<Value>, Y: Into<Value>> From<(T, U, V, W, X, Y)> for Value
impl<T: Into<Value>, U: Into<Value>, V: Into<Value>, W: Into<Value>, X: Into<Value>, Y: Into<Value>> From<(T, U, V, W, X, Y)> for Value
Source§fn from((t, u, v, w, x, y): (T, U, V, W, X, Y)) -> Value
fn from((t, u, v, w, x, y): (T, U, V, W, X, Y)) -> Value
Source§impl<T: Into<Value>, U: Into<Value>, V: Into<Value>, W: Into<Value>, X: Into<Value>, Y: Into<Value>, Z: Into<Value>> From<(T, U, V, W, X, Y, Z)> for Value
impl<T: Into<Value>, U: Into<Value>, V: Into<Value>, W: Into<Value>, X: Into<Value>, Y: Into<Value>, Z: Into<Value>> From<(T, U, V, W, X, Y, Z)> for Value
Source§fn from((t, u, v, w, x, y, z): (T, U, V, W, X, Y, Z)) -> Value
fn from((t, u, v, w, x, y, z): (T, U, V, W, X, Y, Z)) -> Value
Source§impl<T: Into<Value>, U: Into<Value>, V: Into<Value>, W: Into<Value>, X: Into<Value>, Y: Into<Value>, Z: Into<Value>, A: Into<Value>> From<(T, U, V, W, X, Y, Z, A)> for Value
impl<T: Into<Value>, U: Into<Value>, V: Into<Value>, W: Into<Value>, X: Into<Value>, Y: Into<Value>, Z: Into<Value>, A: Into<Value>> From<(T, U, V, W, X, Y, Z, A)> for Value
Source§fn from((t, u, v, w, x, y, z, a): (T, U, V, W, X, Y, Z, A)) -> Value
fn from((t, u, v, w, x, y, z, a): (T, U, V, W, X, Y, Z, A)) -> Value
Source§impl<T: Into<Value>, U: Into<Value>, V: Into<Value>, W: Into<Value>, X: Into<Value>, Y: Into<Value>, Z: Into<Value>, A: Into<Value>, B: Into<Value>> From<(T, U, V, W, X, Y, Z, A, B)> for Value
impl<T: Into<Value>, U: Into<Value>, V: Into<Value>, W: Into<Value>, X: Into<Value>, Y: Into<Value>, Z: Into<Value>, A: Into<Value>, B: Into<Value>> From<(T, U, V, W, X, Y, Z, A, B)> for Value
Source§fn from((t, u, v, w, x, y, z, a, b): (T, U, V, W, X, Y, Z, A, B)) -> Value
fn from((t, u, v, w, x, y, z, a, b): (T, U, V, W, X, Y, Z, A, B)) -> Value
Source§impl<T: Into<Value>, U: Into<Value>, V: Into<Value>, W: Into<Value>, X: Into<Value>, Y: Into<Value>, Z: Into<Value>, A: Into<Value>, B: Into<Value>, C: Into<Value>> From<(T, U, V, W, X, Y, Z, A, B, C)> for Value
impl<T: Into<Value>, U: Into<Value>, V: Into<Value>, W: Into<Value>, X: Into<Value>, Y: Into<Value>, Z: Into<Value>, A: Into<Value>, B: Into<Value>, C: Into<Value>> From<(T, U, V, W, X, Y, Z, A, B, C)> for Value
Source§fn from((t, u, v, w, x, y, z, a, b, c): (T, U, V, W, X, Y, Z, A, B, C)) -> Value
fn from((t, u, v, w, x, y, z, a, b, c): (T, U, V, W, X, Y, Z, A, B, C)) -> Value
Source§impl<T: Into<Value>, U: Into<Value>, V: Into<Value>, W: Into<Value>, X: Into<Value>, Y: Into<Value>, Z: Into<Value>, A: Into<Value>, B: Into<Value>, C: Into<Value>, D: Into<Value>> From<(T, U, V, W, X, Y, Z, A, B, C, D)> for Value
impl<T: Into<Value>, U: Into<Value>, V: Into<Value>, W: Into<Value>, X: Into<Value>, Y: Into<Value>, Z: Into<Value>, A: Into<Value>, B: Into<Value>, C: Into<Value>, D: Into<Value>> From<(T, U, V, W, X, Y, Z, A, B, C, D)> for Value
Source§fn from(
(t, u, v, w, x, y, z, a, b, c, d): (T, U, V, W, X, Y, Z, A, B, C, D),
) -> Value
fn from( (t, u, v, w, x, y, z, a, b, c, d): (T, U, V, W, X, Y, Z, A, B, C, D), ) -> Value
Source§impl<T: Into<Value>, U: Into<Value>, V: Into<Value>, W: Into<Value>, X: Into<Value>, Y: Into<Value>, Z: Into<Value>, A: Into<Value>, B: Into<Value>, C: Into<Value>, D: Into<Value>, E: Into<Value>> From<(T, U, V, W, X, Y, Z, A, B, C, D, E)> for Value
impl<T: Into<Value>, U: Into<Value>, V: Into<Value>, W: Into<Value>, X: Into<Value>, Y: Into<Value>, Z: Into<Value>, A: Into<Value>, B: Into<Value>, C: Into<Value>, D: Into<Value>, E: Into<Value>> From<(T, U, V, W, X, Y, Z, A, B, C, D, E)> for Value
Source§fn from(
(t, u, v, w, x, y, z, a, b, c, d, e): (T, U, V, W, X, Y, Z, A, B, C, D, E),
) -> Value
fn from( (t, u, v, w, x, y, z, a, b, c, d, e): (T, U, V, W, X, Y, Z, A, B, C, D, E), ) -> Value
Source§impl<T: Into<Value>, U: Into<Value>, V: Into<Value>, W: Into<Value>, X: Into<Value>, Y: Into<Value>, Z: Into<Value>, A: Into<Value>, B: Into<Value>, C: Into<Value>, D: Into<Value>, E: Into<Value>, F: Into<Value>> From<(T, U, V, W, X, Y, Z, A, B, C, D, E, F)> for Value
impl<T: Into<Value>, U: Into<Value>, V: Into<Value>, W: Into<Value>, X: Into<Value>, Y: Into<Value>, Z: Into<Value>, A: Into<Value>, B: Into<Value>, C: Into<Value>, D: Into<Value>, E: Into<Value>, F: Into<Value>> From<(T, U, V, W, X, Y, Z, A, B, C, D, E, F)> for Value
Source§fn from(
(t, u, v, w, x, y, z, a, b, c, d, e, f): (T, U, V, W, X, Y, Z, A, B, C, D, E, F),
) -> Value
fn from( (t, u, v, w, x, y, z, a, b, c, d, e, f): (T, U, V, W, X, Y, Z, A, B, C, D, E, F), ) -> Value
Source§impl<T: Into<Value>, U: Into<Value>, V: Into<Value>, W: Into<Value>, X: Into<Value>, Y: Into<Value>, Z: Into<Value>, A: Into<Value>, B: Into<Value>, C: Into<Value>, D: Into<Value>, E: Into<Value>, F: Into<Value>, G: Into<Value>> From<(T, U, V, W, X, Y, Z, A, B, C, D, E, F, G)> for Value
impl<T: Into<Value>, U: Into<Value>, V: Into<Value>, W: Into<Value>, X: Into<Value>, Y: Into<Value>, Z: Into<Value>, A: Into<Value>, B: Into<Value>, C: Into<Value>, D: Into<Value>, E: Into<Value>, F: Into<Value>, G: Into<Value>> From<(T, U, V, W, X, Y, Z, A, B, C, D, E, F, G)> for Value
Source§fn from(
(t, u, v, w, x, y, z, a, b, c, d, e, f, g): (T, U, V, W, X, Y, Z, A, B, C, D, E, F, G),
) -> Value
fn from( (t, u, v, w, x, y, z, a, b, c, d, e, f, g): (T, U, V, W, X, Y, Z, A, B, C, D, E, F, G), ) -> Value
Source§impl<T: Into<Value>, U: Into<Value>, V: Into<Value>, W: Into<Value>, X: Into<Value>, Y: Into<Value>, Z: Into<Value>, A: Into<Value>, B: Into<Value>, C: Into<Value>, D: Into<Value>, E: Into<Value>, F: Into<Value>, G: Into<Value>, H: Into<Value>> From<(T, U, V, W, X, Y, Z, A, B, C, D, E, F, G, H)> for Value
impl<T: Into<Value>, U: Into<Value>, V: Into<Value>, W: Into<Value>, X: Into<Value>, Y: Into<Value>, Z: Into<Value>, A: Into<Value>, B: Into<Value>, C: Into<Value>, D: Into<Value>, E: Into<Value>, F: Into<Value>, G: Into<Value>, H: Into<Value>> From<(T, U, V, W, X, Y, Z, A, B, C, D, E, F, G, H)> for Value
Source§fn from(
(t, u, v, w, x, y, z, a, b, c, d, e, f, g, h): (T, U, V, W, X, Y, Z, A, B, C, D, E, F, G, H),
) -> Value
fn from( (t, u, v, w, x, y, z, a, b, c, d, e, f, g, h): (T, U, V, W, X, Y, Z, A, B, C, D, E, F, G, H), ) -> Value
Source§impl<T: Into<Value>, U: Into<Value>, V: Into<Value>, W: Into<Value>, X: Into<Value>, Y: Into<Value>, Z: Into<Value>, A: Into<Value>, B: Into<Value>, C: Into<Value>, D: Into<Value>, E: Into<Value>, F: Into<Value>, G: Into<Value>, H: Into<Value>, I: Into<Value>> From<(T, U, V, W, X, Y, Z, A, B, C, D, E, F, G, H, I)> for Value
impl<T: Into<Value>, U: Into<Value>, V: Into<Value>, W: Into<Value>, X: Into<Value>, Y: Into<Value>, Z: Into<Value>, A: Into<Value>, B: Into<Value>, C: Into<Value>, D: Into<Value>, E: Into<Value>, F: Into<Value>, G: Into<Value>, H: Into<Value>, I: Into<Value>> From<(T, U, V, W, X, Y, Z, A, B, C, D, E, F, G, H, I)> for Value
Source§fn from(
(t, u, v, w, x, y, z, a, b, c, d, e, f, g, h, i): (T, U, V, W, X, Y, Z, A, B, C, D, E, F, G, H, I),
) -> Value
fn from( (t, u, v, w, x, y, z, a, b, c, d, e, f, g, h, i): (T, U, V, W, X, Y, Z, A, B, C, D, E, F, G, H, I), ) -> Value
Source§impl<T: Into<Value>, U: Into<Value>, V: Into<Value>, W: Into<Value>, X: Into<Value>, Y: Into<Value>, Z: Into<Value>, A: Into<Value>, B: Into<Value>, C: Into<Value>, D: Into<Value>, E: Into<Value>, F: Into<Value>, G: Into<Value>, H: Into<Value>, I: Into<Value>, J: Into<Value>> From<(T, U, V, W, X, Y, Z, A, B, C, D, E, F, G, H, I, J)> for Value
impl<T: Into<Value>, U: Into<Value>, V: Into<Value>, W: Into<Value>, X: Into<Value>, Y: Into<Value>, Z: Into<Value>, A: Into<Value>, B: Into<Value>, C: Into<Value>, D: Into<Value>, E: Into<Value>, F: Into<Value>, G: Into<Value>, H: Into<Value>, I: Into<Value>, J: Into<Value>> From<(T, U, V, W, X, Y, Z, A, B, C, D, E, F, G, H, I, J)> for Value
Source§fn from(
(t, u, v, w, x, y, z, a, b, c, d, e, f, g, h, i, j): (T, U, V, W, X, Y, Z, A, B, C, D, E, F, G, H, I, J),
) -> Value
fn from( (t, u, v, w, x, y, z, a, b, c, d, e, f, g, h, i, j): (T, U, V, W, X, Y, Z, A, B, C, D, E, F, G, H, I, J), ) -> Value
Source§impl<T: Into<Value>, U: Into<Value>, V: Into<Value>, W: Into<Value>, X: Into<Value>, Y: Into<Value>, Z: Into<Value>, A: Into<Value>, B: Into<Value>, C: Into<Value>, D: Into<Value>, E: Into<Value>, F: Into<Value>, G: Into<Value>, H: Into<Value>, I: Into<Value>, J: Into<Value>, K: Into<Value>> From<(T, U, V, W, X, Y, Z, A, B, C, D, E, F, G, H, I, J, K)> for Value
impl<T: Into<Value>, U: Into<Value>, V: Into<Value>, W: Into<Value>, X: Into<Value>, Y: Into<Value>, Z: Into<Value>, A: Into<Value>, B: Into<Value>, C: Into<Value>, D: Into<Value>, E: Into<Value>, F: Into<Value>, G: Into<Value>, H: Into<Value>, I: Into<Value>, J: Into<Value>, K: Into<Value>> From<(T, U, V, W, X, Y, Z, A, B, C, D, E, F, G, H, I, J, K)> for Value
Source§fn from(
(t, u, v, w, x, y, z, a, b, c, d, e, f, g, h, i, j, k): (T, U, V, W, X, Y, Z, A, B, C, D, E, F, G, H, I, J, K),
) -> Value
fn from( (t, u, v, w, x, y, z, a, b, c, d, e, f, g, h, i, j, k): (T, U, V, W, X, Y, Z, A, B, C, D, E, F, G, H, I, J, K), ) -> Value
Source§impl<T: Into<Value>, U: Into<Value>, V: Into<Value>, W: Into<Value>, X: Into<Value>, Y: Into<Value>, Z: Into<Value>, A: Into<Value>, B: Into<Value>, C: Into<Value>, D: Into<Value>, E: Into<Value>, F: Into<Value>, G: Into<Value>, H: Into<Value>, I: Into<Value>, J: Into<Value>, K: Into<Value>, L: Into<Value>> From<(T, U, V, W, X, Y, Z, A, B, C, D, E, F, G, H, I, J, K, L)> for Value
impl<T: Into<Value>, U: Into<Value>, V: Into<Value>, W: Into<Value>, X: Into<Value>, Y: Into<Value>, Z: Into<Value>, A: Into<Value>, B: Into<Value>, C: Into<Value>, D: Into<Value>, E: Into<Value>, F: Into<Value>, G: Into<Value>, H: Into<Value>, I: Into<Value>, J: Into<Value>, K: Into<Value>, L: Into<Value>> From<(T, U, V, W, X, Y, Z, A, B, C, D, E, F, G, H, I, J, K, L)> for Value
Source§fn from(
(t, u, v, w, x, y, z, a, b, c, d, e, f, g, h, i, j, k, l): (T, U, V, W, X, Y, Z, A, B, C, D, E, F, G, H, I, J, K, L),
) -> Value
fn from( (t, u, v, w, x, y, z, a, b, c, d, e, f, g, h, i, j, k, l): (T, U, V, W, X, Y, Z, A, B, C, D, E, F, G, H, I, J, K, L), ) -> Value
Source§impl<T: Into<Value>, U: Into<Value>, V: Into<Value>, W: Into<Value>, X: Into<Value>, Y: Into<Value>, Z: Into<Value>, A: Into<Value>, B: Into<Value>, C: Into<Value>, D: Into<Value>, E: Into<Value>, F: Into<Value>, G: Into<Value>, H: Into<Value>, I: Into<Value>, J: Into<Value>, K: Into<Value>, L: Into<Value>, M: Into<Value>> From<(T, U, V, W, X, Y, Z, A, B, C, D, E, F, G, H, I, J, K, L, M)> for Value
impl<T: Into<Value>, U: Into<Value>, V: Into<Value>, W: Into<Value>, X: Into<Value>, Y: Into<Value>, Z: Into<Value>, A: Into<Value>, B: Into<Value>, C: Into<Value>, D: Into<Value>, E: Into<Value>, F: Into<Value>, G: Into<Value>, H: Into<Value>, I: Into<Value>, J: Into<Value>, K: Into<Value>, L: Into<Value>, M: Into<Value>> From<(T, U, V, W, X, Y, Z, A, B, C, D, E, F, G, H, I, J, K, L, M)> for Value
Source§fn from(
(t, u, v, w, x, y, z, a, b, c, d, e, f, g, h, i, j, k, l, m): (T, U, V, W, X, Y, Z, A, B, C, D, E, F, G, H, I, J, K, L, M),
) -> Value
fn from( (t, u, v, w, x, y, z, a, b, c, d, e, f, g, h, i, j, k, l, m): (T, U, V, W, X, Y, Z, A, B, C, D, E, F, G, H, I, J, K, L, M), ) -> Value
Source§impl From<CompactString> for Value
impl From<CompactString> for Value
Source§fn from(v: CompactString) -> Value
fn from(v: CompactString) -> Value
Source§impl<K: Into<Value>, V: Into<Value>, S: BuildHasher + Default> From<HashMap<K, V, S>> for Value
impl<K: Into<Value>, V: Into<Value>, S: BuildHasher + Default> From<HashMap<K, V, S>> for Value
Source§impl<K: Into<Value>, V: Into<Value>, S: BuildHasher + Default> From<IndexMap<K, V, S>> for Value
impl<K: Into<Value>, V: Into<Value>, S: BuildHasher + Default> From<IndexMap<K, V, S>> for Value
Source§impl FromIterator<Value> for ValArray
impl FromIterator<Value> for ValArray
Source§impl Ord for Value
impl Ord for Value
Source§impl Pack for Value
impl Pack for Value
fn encoded_len(&self) -> usize
fn encode(&self, buf: &mut impl BufMut) -> Result<(), PackError>
fn decode(buf: &mut impl Buf) -> Result<Self, PackError>
fn const_encoded_len() -> Option<usize>
fn decode_into(&mut self, buf: &mut impl Buf) -> Result<(), PackError>where
Self: Sized,
Source§impl PartialOrd for Value
impl PartialOrd for Value
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 !UnwindSafe for Value
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more