pub enum Value {
Show 19 variants
None,
Null,
Bool(bool),
Number(Number),
String(Strand),
Duration(Duration),
Datetime(Datetime),
Uuid(Uuid),
Array(Array),
Set(Set),
Object(Object),
Geometry(Geometry),
Bytes(Bytes),
Table(TableName),
RecordId(RecordId),
File(File),
Regex(Regex),
Range(Box<Range>),
Closure(Box<Closure>),
}Variants§
None
Null
Bool(bool)
Number(Number)
String(Strand)
Duration(Duration)
Datetime(Datetime)
Uuid(Uuid)
Array(Array)
Set(Set)
Object(Object)
Geometry(Geometry)
Bytes(Bytes)
Table(TableName)
RecordId(RecordId)
File(File)
Regex(Regex)
Range(Box<Range>)
Closure(Box<Closure>)
Implementations§
Source§impl Value
impl Value
Sourcepub fn each(&self, path: &[Part]) -> Vec<Idiom>
pub fn each(&self, path: &[Part]) -> Vec<Idiom>
Widens an idiom into a list of idioms with the given object. Resolving .* to all the different fields or indexes in that position.
For example a.*.* with the object { a: { b: [1,2], c: 1} } resolves
to a.b[0], a.b[1], a.c.
and a.$ with object { a: [1,2,3] } resolves to a[2].
Source§impl Value
impl Value
Sourcepub fn every(
&self,
path: Option<&[Part]>,
steps: bool,
behavior: ArrayBehaviour,
) -> Vec<Idiom>
pub fn every( &self, path: Option<&[Part]>, steps: bool, behavior: ArrayBehaviour, ) -> Vec<Idiom>
Returns a list of idioms for then entries of a possibly nested value.
Exact behavior of this function is dictated by the ArrayBehaviour param and steps. Steps enables intermediate idioms instead of only the leaf values. For the changes in behavior with ArrayBehaviour see the docs for that enum.
Source§impl Value
impl Value
Sourcepub fn set_at_field_path_owned(&mut self, path: &FieldPath, val: Value)
pub fn set_at_field_path_owned(&mut self, path: &FieldPath, val: Value)
Synchronous method for setting a value at a FieldPath, consuming val.
Unlike set(), this doesn’t require async/computation - just navigation.
When encountering an array, applies the remaining path to all elements
(cloning val for all-but-last and moving into the last). Otherwise
val is moved straight to the leaf assignment. This is used for output
path navigation in the projection operator, where each computed field
value is produced fresh and would otherwise be cloned into the output.
Source§impl Value
impl Value
pub fn walk(&self, path: &[Part]) -> Vec<(Idiom, Self)>
Sourcepub fn walk_ref(&self, path: &[Part], visit: &mut impl FnMut(&Self))
pub fn walk_ref(&self, path: &[Part], visit: &mut impl FnMut(&Self))
Visits every value Value::walk would return, in the same order, by
reference.
walk answers with owned values and the paths that name them, so a
caller that only measures what it finds deep-clones every match — a
whole array for an array field — and drops it again. This is the same
traversal with the path and the clone left out, and the two must stay
in step: a measurement taken here has to be a measurement of what a
caller reading walk would see.
Source§impl Value
impl Value
pub fn can_cast_to<T: Cast>(&self) -> bool
pub fn can_cast_to_kind(&self, kind: &Kind) -> bool
pub fn cast_to<T: Cast>(self) -> Result<T, CastError>
Sourcepub fn cast_to_kind(self, kind: &Kind) -> Result<Value, CastError>
pub fn cast_to_kind(self, kind: &Kind) -> Result<Value, CastError>
Try to convert this value to the specified Kind
Sourcepub fn cast_to_literal(self, literal: &KindLiteral) -> Result<Value, CastError>
pub fn cast_to_literal(self, literal: &KindLiteral) -> Result<Value, CastError>
Try to convert this value to a Literal, returns a Value with the
coerced value
Sourcepub fn cast_to_set_type(self, kind: &Kind) -> Result<Set, CastError>
pub fn cast_to_set_type(self, kind: &Kind) -> Result<Set, CastError>
Try to convert this value to a Set of a certain type
Sourcepub fn cast_to_set_type_len(
self,
kind: &Kind,
len: u64,
) -> Result<Set, CastError>
pub fn cast_to_set_type_len( self, kind: &Kind, len: u64, ) -> Result<Set, CastError>
Try to convert this value to a Set of a certain type and length
pub fn cast_to_file_buckets(self, buckets: &[String]) -> Result<File, CastError>
Source§impl Value
impl Value
pub fn can_coerce_to<T: Coerce>(&self) -> bool
pub fn can_coerce_to_kind(&self, kind: &Kind) -> bool
Sourcepub fn coerce_to<T: Coerce>(self) -> Result<T, CoerceError>
pub fn coerce_to<T: Coerce>(self) -> Result<T, CoerceError>
Convert the value using coercion rules.
Coercion rules are more strict then coverting rules. Calling this method will succeed if the value can by unified with the kind of the target
This method is a shorthand for T::coerce(self)
Sourcepub fn coerce_to_kind(self, kind: &Kind) -> Result<Value, CoerceError>
pub fn coerce_to_kind(self, kind: &Kind) -> Result<Value, CoerceError>
Try to coerce this value to the specified Kind
Sourcepub fn coerce_to_literal(
self,
literal: &KindLiteral,
) -> Result<Value, CoerceError>
pub fn coerce_to_literal( self, literal: &KindLiteral, ) -> Result<Value, CoerceError>
Try to coerce this value to a Literal, returns a Value with the
coerced value
Sourcepub fn coerce_to_table_kind(
self,
val: &[TableName],
) -> Result<TableName, CoerceError>
pub fn coerce_to_table_kind( self, val: &[TableName], ) -> Result<TableName, CoerceError>
Try to coerce this value to a Table of a certain type
Sourcepub fn coerce_to_record_kind(
self,
val: &[TableName],
) -> Result<RecordId, CoerceError>
pub fn coerce_to_record_kind( self, val: &[TableName], ) -> Result<RecordId, CoerceError>
Try to coerce this value to a Record of a certain type
Sourcepub fn coerce_to_geometry_kind(
self,
val: &[GeometryKind],
) -> Result<Geometry, CoerceError>
pub fn coerce_to_geometry_kind( self, val: &[GeometryKind], ) -> Result<Geometry, CoerceError>
Try to coerce this value to a Geometry of a certain type
Sourcepub fn coerce_to_array_type(self, kind: &Kind) -> Result<Array, CoerceError>
pub fn coerce_to_array_type(self, kind: &Kind) -> Result<Array, CoerceError>
Try to coerce this value to an Array of a certain type
Sourcepub fn coerce_to_array_type_len(
self,
kind: &Kind,
len: u64,
) -> Result<Array, CoerceError>
pub fn coerce_to_array_type_len( self, kind: &Kind, len: u64, ) -> Result<Array, CoerceError>
Try to coerce this value to an Array of a certain type, and length
Sourcepub fn coerce_to_set_kind(self, kind: &Kind) -> Result<Set, CoerceError>
pub fn coerce_to_set_kind(self, kind: &Kind) -> Result<Set, CoerceError>
Try to coerce this value to a Set of a certain type
Sourcepub fn coerce_to_set_kind_len(
self,
kind: &Kind,
len: u64,
) -> Result<Set, CoerceError>
pub fn coerce_to_set_kind_len( self, kind: &Kind, len: u64, ) -> Result<Set, CoerceError>
Try to coerce this value to a Set of a certain type and length
pub fn coerce_to_file_buckets( self, buckets: &[String], ) -> Result<File, CoerceError>
Source§impl Value
impl Value
Sourcepub fn walk_revisioned_variant_name(
wire_revision: u16,
discriminant: u32,
) -> Option<&'static str>
pub fn walk_revisioned_variant_name( wire_revision: u16, discriminant: u32, ) -> Option<&'static str>
Resolve a wire discriminant at wire_revision to the variant
identifier at that revision. Returns None if no such variant
exists at that revision.
Generated by the revisioned derive.
Sourcepub fn walk_revisioned_variant_table(
wire_revision: u16,
) -> &'static [(&'static str, u32)]
pub fn walk_revisioned_variant_table( wire_revision: u16, ) -> &'static [(&'static str, u32)]
Variant name + discriminant pairs at wire_revision. Returns
an empty slice if the revision is unknown. Generated by the
revisioned derive.
Source§impl Value
impl Value
pub const NONE: Self = Self::None
Sourcepub fn hash_agrees_with_eq(&self) -> bool
pub fn hash_agrees_with_eq(&self) -> bool
Whether a HashMap/HashSet miss on this value proves the collection
does not hold it — i.e. whether this value’s Hash is
consistent with its PartialEq.
Number is the one leaf where the two disagree, and it cannot be
repaired: see Number’s Hash impl for why. A value that can reach a
Number may hash into a different bucket than an equal value, so
contains answers false for something the collection holds.
A probe is decisive as soon as either side is number-free, because
equality requires matching variants at every level: two values can only
hash apart while comparing equal if both carry a Number in the same
position. So a caller may trust a miss when this returns true for the
probed value, or when it returns true for every element of the
collection.
Variants whose hash/equality pairing is not established — Value::Geometry
(hashes f64 coordinates), Value::Regex (equality with
Value::String is asymmetric), Value::Range and Value::Closure —
report false so they take the same conservative path.
Sourcepub fn empty_object() -> Self
pub fn empty_object() -> Self
Create an empty Object Value
Sourcepub fn is_nullish(&self) -> bool
pub fn is_nullish(&self) -> bool
Check if this Value is NONE or NULL
Sourcepub fn is_empty_array(&self) -> bool
pub fn is_empty_array(&self) -> bool
Check if this Value is NONE
Sourcepub fn is_decimal(&self) -> bool
pub fn is_decimal(&self) -> bool
Check if this Value is a decimal Number
Sourcepub fn is_record_type(&self, types: &[TableName]) -> bool
pub fn is_record_type(&self, types: &[TableName]) -> bool
Check if this Value is a RecordId of a specific type
Sourcepub fn is_geometry_type(&self, types: &[GeometryKind]) -> bool
pub fn is_geometry_type(&self, types: &[GeometryKind]) -> bool
Check if this Value is a Geometry of a specific type
Sourcepub fn into_raw_string(self) -> String
pub fn into_raw_string(self) -> String
Converts this Value into an unquoted String
Sourcepub fn to_raw_string(&self) -> String
pub fn to_raw_string(&self) -> String
Converts this Value into an unquoted String
Sourcepub fn kind_of(&self) -> &'static str
pub fn kind_of(&self) -> &'static str
Returns the surql representation of the kind of the value as a string.
§Warning
This function is not fully implement for all variants, make sure you don’t accidentally use it where it can return an invalid value.
Sourcepub fn all_equal(&self, other: &Value) -> bool
pub fn all_equal(&self, other: &Value) -> bool
Check if all Values in an Array are equal to another Value
Sourcepub fn any_equal(&self, other: &Value) -> bool
pub fn any_equal(&self, other: &Value) -> bool
Check if any Values in an Array are equal to another Value
Sourcepub fn contains_all(&self, other: &Value) -> bool
pub fn contains_all(&self, other: &Value) -> bool
Check if all Values in an Array, Set or String contain another Value
Sourcepub fn contains_any(&self, other: &Value) -> bool
pub fn contains_any(&self, other: &Value) -> bool
Check if any Values in an Array, Set or String contain another Value
Sourcepub fn intersects(&self, other: &Value) -> bool
pub fn intersects(&self, other: &Value) -> bool
Check if this Geometry intersects another Value
Sourcepub fn lexical_cmp(&self, other: &Value) -> Option<Ordering>
pub fn lexical_cmp(&self, other: &Value) -> Option<Ordering>
Compare this Value to another Value lexicographically
Sourcepub fn natural_cmp(&self, other: &Value) -> Option<Ordering>
pub fn natural_cmp(&self, other: &Value) -> Option<Ordering>
Compare this Value to another Value using natural numerical comparison
Sourcepub fn natural_lexical_cmp(&self, other: &Value) -> Option<Ordering>
pub fn natural_lexical_cmp(&self, other: &Value) -> Option<Ordering>
Compare this Value to another Value lexicographically and using natural numerical comparison
Sourcepub fn into_literal(self) -> Expr
pub fn into_literal(self) -> Expr
Turns this value into a literal evaluating to the same value.
Source§impl Value
impl Value
Sourcepub fn as_bool(&self) -> Option<&bool>
pub fn as_bool(&self) -> Option<&bool>
Return a reference to [Bool] if the value is of that type
Sourcepub fn into_bool(self) -> Option<bool>
pub fn into_bool(self) -> Option<bool>
Turns the value into a [Bool] returning None if the value is not of that type
Sourcepub fn as_number(&self) -> Option<&Number>
pub fn as_number(&self) -> Option<&Number>
Return a reference to Number if the value is of that type
Sourcepub fn into_number(self) -> Option<Number>
pub fn into_number(self) -> Option<Number>
Turns the value into a Number returning None if the value is not of that type
Sourcepub fn as_strand(&self) -> Option<&Strand>
pub fn as_strand(&self) -> Option<&Strand>
Return a reference to String if the value is of that type
Sourcepub fn into_strand(self) -> Option<Strand>
pub fn into_strand(self) -> Option<Strand>
Turns the value into a String returning None if the value is not of that type
Sourcepub fn as_table(&self) -> Option<&TableName>
pub fn as_table(&self) -> Option<&TableName>
Return a reference to [Table] if the value is of that type
Sourcepub fn into_table(self) -> Option<TableName>
pub fn into_table(self) -> Option<TableName>
Turns the value into a [Table] returning None if the value is not of that type
Sourcepub fn is_duration(&self) -> bool
pub fn is_duration(&self) -> bool
Check if the value is a Duration
Sourcepub fn as_duration(&self) -> Option<&Duration>
pub fn as_duration(&self) -> Option<&Duration>
Return a reference to Duration if the value is of that type
Sourcepub fn into_duration(self) -> Option<Duration>
pub fn into_duration(self) -> Option<Duration>
Turns the value into a Duration returning None if the value is not of that type
Sourcepub fn is_datetime(&self) -> bool
pub fn is_datetime(&self) -> bool
Check if the value is a Datetime
Sourcepub fn as_datetime(&self) -> Option<&Datetime>
pub fn as_datetime(&self) -> Option<&Datetime>
Return a reference to Datetime if the value is of that type
Sourcepub fn into_datetime(self) -> Option<Datetime>
pub fn into_datetime(self) -> Option<Datetime>
Turns the value into a Datetime returning None if the value is not of that type
Sourcepub fn into_uuid(self) -> Option<Uuid>
pub fn into_uuid(self) -> Option<Uuid>
Turns the value into a Uuid returning None if the value is not of that type
Sourcepub fn as_array(&self) -> Option<&Array>
pub fn as_array(&self) -> Option<&Array>
Return a reference to Array if the value is of that type
Sourcepub fn into_array(self) -> Option<Array>
pub fn into_array(self) -> Option<Array>
Turns the value into a Array returning None if the value is not of that type
Sourcepub fn into_set(self) -> Option<Set>
pub fn into_set(self) -> Option<Set>
Turns the value into a Set returning None if the value is not of that type
Sourcepub fn as_object(&self) -> Option<&Object>
pub fn as_object(&self) -> Option<&Object>
Return a reference to Object if the value is of that type
Sourcepub fn into_object(self) -> Option<Object>
pub fn into_object(self) -> Option<Object>
Turns the value into a Object returning None if the value is not of that type
Sourcepub fn is_geometry(&self) -> bool
pub fn is_geometry(&self) -> bool
Check if the value is a Geometry
Sourcepub fn as_geometry(&self) -> Option<&Geometry>
pub fn as_geometry(&self) -> Option<&Geometry>
Return a reference to Geometry if the value is of that type
Sourcepub fn into_geometry(self) -> Option<Geometry>
pub fn into_geometry(self) -> Option<Geometry>
Turns the value into a Geometry returning None if the value is not of that type
Sourcepub fn as_bytes(&self) -> Option<&Bytes>
pub fn as_bytes(&self) -> Option<&Bytes>
Return a reference to Bytes if the value is of that type
Sourcepub fn into_bytes(self) -> Option<Bytes>
pub fn into_bytes(self) -> Option<Bytes>
Turns the value into a Bytes returning None if the value is not of that type
Sourcepub fn as_record(&self) -> Option<&RecordId>
pub fn as_record(&self) -> Option<&RecordId>
Return a reference to RecordId if the value is of that type
Sourcepub fn into_record(self) -> Option<RecordId>
pub fn into_record(self) -> Option<RecordId>
Turns the value into a RecordId returning None if the value is not of that type
Sourcepub fn as_regex(&self) -> Option<&Regex>
pub fn as_regex(&self) -> Option<&Regex>
Return a reference to Regex if the value is of that type
Sourcepub fn into_regex(self) -> Option<Regex>
pub fn into_regex(self) -> Option<Regex>
Turns the value into a Regex returning None if the value is not of that type
Sourcepub fn as_range(&self) -> Option<&Box<Range>>
pub fn as_range(&self) -> Option<&Box<Range>>
Return a reference to Range if the value is of that type
Sourcepub fn into_range(self) -> Option<Box<Range>>
pub fn into_range(self) -> Option<Box<Range>>
Turns the value into a Range returning None if the value is not of that type
Sourcepub fn is_closure(&self) -> bool
pub fn is_closure(&self) -> bool
Check if the value is a Closure
Sourcepub fn as_closure(&self) -> Option<&Box<Closure>>
pub fn as_closure(&self) -> Option<&Box<Closure>>
Return a reference to Closure if the value is of that type
Trait Implementations§
Source§impl<'de> BorrowDecode<'de, IndexFormat> for Value
impl<'de> BorrowDecode<'de, IndexFormat> for Value
fn borrow_decode(_r: &mut BorrowReader<'de>) -> Result<Self, DecodeError>
Source§impl<'de> BorrowDecode<'de> for Value
impl<'de> BorrowDecode<'de> for Value
fn borrow_decode(_r: &mut BorrowReader<'de>) -> Result<Self, DecodeError>
Source§impl DeserializeRevisioned for Value
impl DeserializeRevisioned for Value
Source§impl Encode<IndexFormat> for Value
impl Encode<IndexFormat> for Value
impl Eq for Value
Source§impl From<Value> for Value
impl From<Value> for Value
Source§fn from(s: PublicValue) -> Self
fn from(s: PublicValue) -> Self
Source§impl FromIterator<Value> for Array
impl FromIterator<Value> for Array
Source§impl FromIterator<Value> for Set
impl FromIterator<Value> for Set
Source§impl FromIterator<Value> for Value
impl FromIterator<Value> for Value
Source§impl Ord for Value
impl Ord for Value
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq<Value> for RecordIdKey
impl PartialEq<Value> for RecordIdKey
Source§impl PartialOrd for Value
impl PartialOrd for Value
Source§impl Revisioned for Value
impl Revisioned for Value
Source§impl SerializeRevisioned for Value
impl SerializeRevisioned for Value
Source§impl SkipCheckRevisioned for Value
impl SkipCheckRevisioned for Value
Source§impl SkipRevisioned for Value
impl SkipRevisioned for Value
fn skip_revisioned<R: Read>(reader: &mut R) -> Result<(), Error>
Source§fn skip_revisioned_slice(reader: &mut SliceReader<'_>) -> Result<(), Error>
fn skip_revisioned_slice(reader: &mut SliceReader<'_>) -> Result<(), Error>
SliceReader without allocating a buffer for bulk segments. Read moreimpl StructuralPartialEq for Value
Source§impl TryFloatDiv for Value
impl TryFloatDiv for Value
Source§impl TryFrom<Value> for PublicValue
impl TryFrom<Value> for PublicValue
Source§impl WalkRevisioned for Value
impl WalkRevisioned for Value
Source§type Walker<'r, R: BorrowedReader + 'r> = ValueWalker<'r, R>
type Walker<'r, R: BorrowedReader + 'r> = ValueWalker<'r, R>
walk_revisioned. Read moreSource§fn walk_revisioned<'r, R: BorrowedReader>(
reader: &'r mut R,
) -> Result<Self::Walker<'r, R>, Error>
fn walk_revisioned<'r, R: BorrowedReader>( reader: &'r mut R, ) -> Result<Self::Walker<'r, R>, Error>
Auto Trait Implementations§
impl !Freeze for Value
impl !RefUnwindSafe for Value
impl !UnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnsafeUnpin 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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.