pub struct QueryUsing<'q, C, L: Lt> { /* private fields */ }Expand description
Packs a context value of type C alongside the query that will be passed to a function
fulfilling the query.
See Query::using().
Implementations§
Source§impl<C, L: Lt> QueryUsing<'_, C, L>
 
impl<C, L: Lt> QueryUsing<'_, C, L>
Sourcepub fn finish(self) -> Option<C>
 
pub fn finish(self) -> Option<C>
Releases the context value, if still available.
Returns Some(_) if the query was not fulfilled, so the context was never used.
Returns None if the query was fulfilled.
Sourcepub fn is_fulfilled(&self) -> bool
 
pub fn is_fulfilled(&self) -> bool
Returns true if the query has been fulfilled and no values will be accepted in the future.
Sourcepub fn expects<Tag: TagFor<L>>(&self) -> bool
 
pub fn expects<Tag: TagFor<L>>(&self) -> bool
Returns true if this query would accept a value tagged with Tag.
Note: this will return false if a value tagged with Tag was expected and has been
fulfilled, as it will not accept additional values.
Sourcepub fn expected_tag_id(&self) -> TagId
 
pub fn expected_tag_id(&self) -> TagId
Returns the TagId expected by this query.
If this query has already been fulfilled, the returned ID is unspecified.
Sourcepub fn put<Tag: TagFor<L>>(self, f: impl FnOnce(C) -> Tag::Value) -> Self
 
pub fn put<Tag: TagFor<L>>(self, f: impl FnOnce(C) -> Tag::Value) -> Self
Attempts to fulfill the query using a function accepting C and returning a value marked by
Tag.
If Tag is not expected, the function will not be called and the context will not be used.
Does nothing if the query has already been fulfilled.
Sourcepub fn put_with_arg<Tag: TagFor<L>>(
    self,
    f: impl FnOnce(Tag::ArgValue, C) -> Tag::Value,
) -> Self
 
pub fn put_with_arg<Tag: TagFor<L>>( self, f: impl FnOnce(Tag::ArgValue, C) -> Tag::Value, ) -> Self
Attempts to fulfill the query using a function accepting Tag::ArgValue and C and
returning a value marked by Tag.
If Tag is not expected, the function will not be called and the context will not be used.
Does nothing if the query has already been fulfilled.
Sourcepub fn put_where<Tag: TagFor<L>>(
    self,
    predicate: impl FnOnce(&mut Tag::ArgValue, &mut C) -> bool,
    f: impl FnOnce(Tag::ArgValue, C) -> Tag::Value,
) -> Self
 
pub fn put_where<Tag: TagFor<L>>( self, predicate: impl FnOnce(&mut Tag::ArgValue, &mut C) -> bool, f: impl FnOnce(Tag::ArgValue, C) -> Tag::Value, ) -> Self
Behaves like Self::put_with_arg(), except that the query is not fulfilled if predicate returns false.
If Tag is not expected or predicate returns false,
the function will not be called and the context will not be used.
Does nothing if the query has already been fulfilled.
Sourcepub fn try_put<Tag: TagFor<L>>(
    self,
    f: impl FnOnce(C) -> Result<Tag::Value, C>,
) -> Self
 
pub fn try_put<Tag: TagFor<L>>( self, f: impl FnOnce(C) -> Result<Tag::Value, C>, ) -> Self
Behaves like Self::put() when the given function returns Ok(_).
When the function returns Err(context), the query is not fulfilled and the context will be usable again.
Sourcepub fn try_put_with_arg<Tag: TagFor<L>>(
    self,
    f: impl FnOnce(Tag::ArgValue, C) -> Result<Tag::Value, (Tag::ArgValue, C)>,
) -> Self
 
pub fn try_put_with_arg<Tag: TagFor<L>>( self, f: impl FnOnce(Tag::ArgValue, C) -> Result<Tag::Value, (Tag::ArgValue, C)>, ) -> Self
Behaves like Self::put_with_arg() when the given function returns Ok(_).
When the function returns Err((arg, context)), the query is not fulfilled and the context will be usable again.
Sourcepub fn put_value<T: 'static>(self, f: impl FnOnce(C) -> T) -> Self
 
pub fn put_value<T: 'static>(self, f: impl FnOnce(C) -> T) -> Self
Attempts to fulfill the query using a function accepting C and returning a T marked by
Value<T>.
If the value is not expected, the function will not be called and the context will not be used. Does nothing if the query has already been fulfilled.
Source§impl<'x, C, L: Lt> QueryUsing<'_, C, LtList<'x, L>>
 
impl<'x, C, L: Lt> QueryUsing<'_, C, LtList<'x, L>>
Sourcepub fn put_ref<T: 'static + ?Sized>(self, f: impl FnOnce(C) -> &'x T) -> Self
 
pub fn put_ref<T: 'static + ?Sized>(self, f: impl FnOnce(C) -> &'x T) -> Self
Attempts to fulfill the query using a function accepting C and returning a &'x T marked by
Ref<Value<T>>.
If the reference is not expected, the function will not be called and the context will not be used. Does nothing if the query has already been fulfilled.
Sourcepub fn put_mut<T: 'static + ?Sized>(
    self,
    f: impl FnOnce(C) -> &'x mut T,
) -> Self
 
pub fn put_mut<T: 'static + ?Sized>( self, f: impl FnOnce(C) -> &'x mut T, ) -> Self
Attempts to fulfill the query using a function accepting C and returning a &'x mut T marked by
Mut<Value<T>>.
If the reference is not expected, the function will not be called and the context will not be used. Does nothing if the query has already been fulfilled.
Sourcepub fn put_cloneable<T>(self, f: impl FnOnce(C) -> &'x T) -> Selfwhere
    T: 'static + Clone,
 
pub fn put_cloneable<T>(self, f: impl FnOnce(C) -> &'x T) -> Selfwhere
    T: 'static + Clone,
Attempts to fulfill the query using a function accepting C and returning a &'x T.
This will supply the &'x T marked by Ref<Value<T>>
as well as the T marked by Value<T>
using T’s Clone implementation.
Behaves similarly to Self::put_ownable() but is available when the alloc feature is disabled.
If neither the reference nor the owned value are expected, the function will not be called and the context will not be used. Does nothing if the query has already been fulfilled.
Sourcepub fn put_ownable<T>(self, f: impl FnOnce(C) -> &'x T) -> Self
 Available on crate feature alloc only.
pub fn put_ownable<T>(self, f: impl FnOnce(C) -> &'x T) -> Self
alloc only.Attempts to fulfill the query using a function accepting C and returning a &'x T.
This will supply the &'x T marked by Ref<Value<T>>
as well as the T::Owned marked by Value<T::Owned>
using T's ToOwned implementation.
If neither the reference nor the owned value are expected, the function will not be called and the context will not be used. Does nothing if the query has already been fulfilled.