pub struct PreparedFetch<T, E> {
pub entity: Entity<QueryResource<T, E>>,
pub request_id: RequestId,
pub signal: QuerySignal,
/* private fields */
}client only.Expand description
A prepared fetch returned by [QueryClient::prepare_fetch_query] or
[QueryClient::prepare_prefetch_query].
Contains the entity, request ID, and cooperative cancellation signal needed to perform the async fetch and complete the resource.
The caller should:
- Call their fetcher with
self.signal - Use
complete_successorcomplete_failurewith the result
§Example
use gpui_query::client::QueryClient;
use gpui_query::core::QueryKey;
let prepared = client.prepare_fetch_query::<Data, Error>(key, cx).unwrap();
let signal = prepared.signal.clone();
// Use cx.spawn() to run your async fetcher with the signal, then call
// prepared.complete_success(data, cx) or prepared.complete_failure(e, cx).Fields§
§entity: Entity<QueryResource<T, E>>The query resource entity.
request_id: RequestIdThe request ID for the started request.
signal: QuerySignalThe cooperative cancellation signal for the in-flight request.
Implementations§
Source§impl<T: Clone + Send + Sync + 'static, E: Clone + Send + Sync + 'static> PreparedFetch<T, E>
impl<T: Clone + Send + Sync + 'static, E: Clone + Send + Sync + 'static> PreparedFetch<T, E>
Sourcepub fn complete_success(self, data: T, cx: &mut App)
pub fn complete_success(self, data: T, cx: &mut App)
Complete the fetch with success.
Calls complete_current_success on the resource entity. If the request
ID is no longer active (replaced by a newer request), this is a no-op.
M3: reuses the now_ms captured at prepare time instead of
re-syscalling current_time_ms().
Sourcepub fn complete_failure(self, error: E, cx: &mut App)
pub fn complete_failure(self, error: E, cx: &mut App)
Complete the fetch with failure.
Calls complete_current_failure on the resource entity. If the request
ID is no longer active (replaced by a newer request), this is a no-op.
M3: reuses the now_ms captured at prepare time instead of
re-syscalling current_time_ms().
Auto Trait Implementations§
impl<T, E> !RefUnwindSafe for PreparedFetch<T, E>
impl<T, E> !UnwindSafe for PreparedFetch<T, E>
impl<T, E> Freeze for PreparedFetch<T, E>
impl<T, E> Send for PreparedFetch<T, E>
impl<T, E> Sync for PreparedFetch<T, E>
impl<T, E> Unpin for PreparedFetch<T, E>
impl<T, E> UnsafeUnpin for PreparedFetch<T, E>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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