pub struct DataContext<Vertex> { /* private fields */ }Expand description
A partial result of a Trustfall query within the interpreter defined in this module.
Implementations§
Source§impl<Vertex> DataContext<Vertex>
impl<Vertex> DataContext<Vertex>
Sourcepub fn active_vertex<V>(&self) -> Option<&V>where
Vertex: AsVertex<V>,
pub fn active_vertex<V>(&self) -> Option<&V>where
Vertex: AsVertex<V>,
The vertex currently being processed.
For contexts passed to an Adapter resolver method,
this is the vertex whose data needs to be resolved.
The active vertex may be None when processing an @optional part
of a Trustfall query whose data did not exist. In that case:
Adapter::resolve_propertymust produceFieldValue::Nullfor that context.Adapter::resolve_neighborsmust produce an empty iterator of neighbors such asBox::new(std::iter::empty())for that context.Adapter::resolve_coercionmust produce afalsecoercion outcome for that context.
Sourcepub fn map<Other>(
self,
mapper: &mut impl FnMut(Vertex) -> Other,
) -> DataContext<Other>
pub fn map<Other>( self, mapper: &mut impl FnMut(Vertex) -> Other, ) -> DataContext<Other>
Converts DataContext<Vertex> to DataContext<Other> by mapping each Vertex to Other.
If you are implementing an Adapter for a data source,
you almost certainly should not be using this function.
You’re probably looking for DataContext::active_vertex() instead.
Sourcepub fn flat_map<T>(
self,
mapper: &mut impl FnMut(Vertex) -> Option<T>,
) -> DataContext<T>
pub fn flat_map<T>( self, mapper: &mut impl FnMut(Vertex) -> Option<T>, ) -> DataContext<T>
Map each Vertex to Option<Other>, thus converting Self to DataContext<Other>.
This is the DataContext equivalent of Option::and_then, which is also
referred to as “flat-map” in some languages.
If you are implementing an Adapter for a data source,
you almost certainly should not be using this function.
You’re probably looking for DataContext::active_vertex() instead.
Source§impl<Vertex> DataContext<Vertex>
impl<Vertex> DataContext<Vertex>
pub fn new(vertex: Option<Vertex>) -> DataContext<Vertex>
Trait Implementations§
Source§impl<Vertex> Clone for DataContext<Vertex>where
Vertex: Clone,
impl<Vertex> Clone for DataContext<Vertex>where
Vertex: Clone,
Source§fn clone(&self) -> DataContext<Vertex>
fn clone(&self) -> DataContext<Vertex>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<Vertex> Debug for DataContext<Vertex>where
Vertex: Debug,
impl<Vertex> Debug for DataContext<Vertex>where
Vertex: Debug,
Source§impl<'de, Vertex> Deserialize<'de> for DataContext<Vertex>
impl<'de, Vertex> Deserialize<'de> for DataContext<Vertex>
Source§fn deserialize<D>(
deserializer: D,
) -> Result<DataContext<Vertex>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<DataContext<Vertex>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<Vertex> From<SerializableContext<Vertex>> for DataContext<Vertex>
impl<Vertex> From<SerializableContext<Vertex>> for DataContext<Vertex>
Source§fn from(context: SerializableContext<Vertex>) -> DataContext<Vertex>
fn from(context: SerializableContext<Vertex>) -> DataContext<Vertex>
Source§impl<Vertex> PartialEq for DataContext<Vertex>where
Vertex: PartialEq,
impl<Vertex> PartialEq for DataContext<Vertex>where
Vertex: PartialEq,
Source§impl<Vertex> Serialize for DataContext<Vertex>
impl<Vertex> Serialize for DataContext<Vertex>
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
impl<Vertex> Eq for DataContext<Vertex>where
Vertex: Eq,
Auto Trait Implementations§
impl<Vertex> Freeze for DataContext<Vertex>where
Vertex: Freeze,
impl<Vertex> RefUnwindSafe for DataContext<Vertex>where
Vertex: RefUnwindSafe,
impl<Vertex> Send for DataContext<Vertex>where
Vertex: Send,
impl<Vertex> Sync for DataContext<Vertex>where
Vertex: Sync,
impl<Vertex> Unpin for DataContext<Vertex>where
Vertex: Unpin,
impl<Vertex> UnwindSafe for DataContext<Vertex>where
Vertex: UnwindSafe + RefUnwindSafe,
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> 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
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more