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 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
Mutably borrows from an owned value. Read more
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
Compare self to
key
and return true
if they are equal.