pub struct FieldPath(pub Vec<FieldPathPart>);Expand description
A path for pure field extraction, with no execution required.
This is a validated subset of Idiom that only contains parts that can be
extracted synchronously from a Value without database access or expression
evaluation.
Supported patterns:
a- simple fielda.b.c- nested fieldsa[0]- array indexa[$]- last elementa[0].b.c- mixed
§Examples
ⓘ
use surrealdb::exec::FieldPath;
// Simple field
let path = FieldPath::field("name");
// Convert from idiom (may fail for complex idioms)
let idiom = syn::idiom("user.address.city").unwrap();
let path = FieldPath::try_from(&idiom)?;Tuple Fields§
§0: Vec<FieldPathPart>Implementations§
Source§impl FieldPath
impl FieldPath
Sourcepub fn extract<'a>(&self, value: &'a Value) -> Cow<'a, Value>
pub fn extract<'a>(&self, value: &'a Value) -> Cow<'a, Value>
Extract the value at this path from a record. Returns Value::None if the path doesn’t exist.
Borrows into the input wherever the path is pure navigation
(object fields, array/set element access), so the common case —
a sort key like a.b.c — never clones the record. An owned value
is produced only for synthesised results (field projection over an
array/set, missing paths) or when descending through one.
Trait Implementations§
impl Eq for FieldPath
impl StructuralPartialEq for FieldPath
Auto Trait Implementations§
impl Freeze for FieldPath
impl RefUnwindSafe for FieldPath
impl Send for FieldPath
impl Sync for FieldPath
impl Unpin for FieldPath
impl UnsafeUnpin for FieldPath
impl UnwindSafe for FieldPath
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> 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.