pub enum Value {
Null,
Int64(i64),
Float64(f64),
Boolean(bool),
String(String),
Bytes(Vec<u8>),
Array(Vec<Value>),
Object(BTreeMap<String, Value>),
}
Expand description
A value that can be passed as an argument or returned from Convex functions. They correspond to the supported Convex types.
Variants§
Null
Int64(i64)
Float64(f64)
Boolean(bool)
String(String)
Bytes(Vec<u8>)
Array(Vec<Value>)
Object(BTreeMap<String, Value>)
Implementations§
source§impl Value
impl Value
sourcepub fn export(self) -> JsonValue
pub fn export(self) -> JsonValue
Converts this value to a JSON value in the json
export format.
https://docs.convex.dev/database/types
It is possible for distinct Convex values to be serialized to the same
JSON value by this method. For instance, strings and binary values are
both exported as JSON strings. However, it is possible to convert the
exported value back to a unique Convex value if you also have the Type
value associated with the original Convex value (see roundtrip.rs
).
§Example
use convex::Value;
use serde_json::{
json,
Value as JsonValue,
};
let value = Value::Bytes(vec![0b00000000, 0b00010000, 0b10000011]);
assert_eq!(JsonValue::from(value.clone()), json!({ "$bytes": "ABCD" }));
assert_eq!(value.export(), json!("ABCD"));
Trait Implementations§
source§impl Ord for Value
impl Ord for Value
source§impl PartialEq for Value
impl PartialEq for Value
source§impl PartialOrd for Value
impl PartialOrd for Value
1.0.0 · source§fn 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§
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
Mutably borrows from an owned value. Read more
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
Compare self to
key
and return true
if they are equal.