[−][src]Enum faunadb::client::Value
Represents any value returned from Fauna.
Read the docs
Variants
Annotated(AnnotatedValue)
A value with an annotation for its type definition.
Simple(SimpleValue)
A value with a direct mapping to the types supported in JSON.
Methods
impl Value
[src]
pub const fn null() -> Value
[src]
A helper to get a Null
value.
pub fn get<I: ValueIndex>(&self, index: I) -> Option<&Value>
[src]
Index into a Fauna Array
or Object
. A string index can be used to
access a value in an Object
, and a usize index can be used to access
an element of an Array
.
Returns None
if the type of self
does not match the type of the index
or the given key does not exist in the map or the given index is not
within the bounds of the array.
let mut obj = BTreeMap::new(); obj.insert("foo", "bar"); let value = Value::from(vec![obj]); assert_eq!(Some("bar"), value[0]["foo"].as_str());
pub fn get_mut<I: ValueIndex>(&mut self, index: I) -> Option<&mut Value>
[src]
Mutably index into a Fauna Array
or Object
. A string index can be
used to access a value in an Object
, and a usize index can be used to
access an element of an Array
.
Returns None
if the type of self
does not match the type of the index
or the given key does not exist in the map or the given index is not
within the bounds of the array.
let mut obj = BTreeMap::new(); obj.insert("cat", "purr"); let mut obj_value = Value::from(obj); *obj_value.get_mut("cat").unwrap() = Value::from("meow"); let mut ary_value = Value::from(vec!["meow"]); *ary_value.get_mut(0).unwrap() = Value::from("purr");
pub fn is_string(&self) -> bool
[src]
true
if the Value
is a String
.
pub fn as_str(&self) -> Option<&str>
[src]
Returns a &str if the value is a String
, otherwise None
.
pub fn into_string(self) -> Option<String>
[src]
Transforms the Value
to a String
if it's a string, otherwise None
.
pub fn is_number(&self) -> bool
[src]
true
if the Value
is a Number
.
pub fn as_number(&self) -> Option<Number>
[src]
Returns a Number
for number values, otherwise None
.
pub fn is_u64(&self) -> bool
[src]
true
if the Value
is a u64
.
pub fn as_u64(&self) -> Option<u64>
[src]
Returns a u64
for u64
values, otherwise None
.
pub fn is_i64(&self) -> bool
[src]
true
if the Value
is a i64
.
pub fn as_i64(&self) -> Option<i64>
[src]
Returns a i64
for i64
values, otherwise None
.
pub fn is_f64(&self) -> bool
[src]
true
if the Value
is a f64
.
pub fn as_f64(&self) -> Option<f64>
[src]
Returns a f64
for f64
values, otherwise None
.
pub fn is_f32(&self) -> bool
[src]
true
if the Value
is a f32
.
pub fn as_f32(&self) -> Option<f32>
[src]
Returns a f32
for f32
values, otherwise None
.
pub fn is_bool(&self) -> bool
[src]
true
if the Value
is a bool
.
pub fn as_bool(&self) -> Option<bool>
[src]
Returns a bool
for bool
values, otherwise None
.
pub fn is_array(&self) -> bool
[src]
true
if the Value
is an Array
.
pub fn as_array(&self) -> Option<&Vec<Value>>
[src]
Returns an Array
for Array
values, otherwise None
.
pub fn into_array(self) -> Option<Vec<Value>>
[src]
Transforms the Value
into an Array
if an array, otherwise None
.
pub fn as_array_mut(&mut self) -> Option<&Vec<Value>>
[src]
Returns a mutable Array
for Array
values, otherwise None
.
pub fn is_object(&self) -> bool
[src]
true
if the Value
is an Object
.
pub fn as_object(&self) -> Option<&BTreeMap<String, Value>>
[src]
Returns an Object
for Object
values, otherwise None
.
pub fn as_object_mut(&mut self) -> Option<&mut BTreeMap<String, Value>>
[src]
Returns a mutable Object
for Object
values, otherwise None
.
pub fn into_object(self) -> Option<BTreeMap<String, Value>>
[src]
Transforms the Value
into an Object
if an object, otherwise None
.
pub fn is_null(&self) -> bool
[src]
true
if the Value
is Null
.
pub fn is_reference(&self) -> bool
[src]
true
if the Value
is a Ref
.
pub fn as_reference(&self) -> Option<&Ref<'static>>
[src]
Returns a Ref
for Ref
values, otherwise None
.
pub fn get_reference(&self) -> Option<&Ref<'static>>
[src]
Finds a nearest Ref
if found and if taken from an Object
, otherwise
None
.
pub fn is_query(&self) -> bool
[src]
true
if the Value
is a Query
.
pub fn as_query(&self) -> Option<&Value>
[src]
Returns a Query
for Query
values, otherwise None
.
pub fn is_bytes(&self) -> bool
[src]
true
if the Value
is a set of Bytes
.
pub fn as_bytes(&self) -> Option<&Bytes<'static>>
[src]
Returns Bytes
for sets of Bytes
, otherwise None
.
pub fn is_date(&self) -> bool
[src]
true
if the Value
is a Date
.
pub fn as_date(&self) -> Option<NaiveDate>
[src]
Returns a NaiveDate
for Date
values, otherwise None
.
pub fn is_set(&self) -> bool
[src]
true
if the Value
is a Set
.
pub fn as_set(&self) -> Option<&Value>
[src]
Returns a Set
for Set
values, otherwise None
.
pub fn is_timestamp(&self) -> bool
[src]
true
if the Value
is a Timestamp
.
pub fn as_timestamp(&self) -> Option<DateTime<Utc>>
[src]
Returns a DateTime
for Timestamp
values, otherwise None
.
Trait Implementations
impl PartialEq<Value> for Value
[src]
impl Default for Value
[src]
impl<'a> From<&'a str> for Value
[src]
impl<T> From<T> for Value where
T: Into<Number>,
[src]
T: Into<Number>,
impl From<Ref<'static>> for Value
[src]
impl From<NaiveDate> for Value
[src]
impl From<DateTime<Utc>> for Value
[src]
impl<V> From<Vec<V>> for Value where
V: Into<Value>,
[src]
V: Into<Value>,
impl<S, V> From<BTreeMap<S, V>> for Value where
S: Into<String>,
V: Into<Value>,
[src]
S: Into<String>,
V: Into<Value>,
impl Clone for Value
[src]
fn clone(&self) -> Value
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<I: ValueIndex> Index<I> for Value
[src]
impl Debug for Value
[src]
impl Serialize for Value
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<'de> Deserialize<'de> for Value
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
Auto Trait Implementations
impl Sync for Value
impl Send for Value
impl Unpin for Value
impl RefUnwindSafe for Value
impl UnwindSafe for Value
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,