pub struct Client { /* private fields */ }
Expand description
Apollo client.
Implementations§
Source§impl Client
impl Client
Sourcepub async fn start(&mut self) -> Result<(), Error>
pub async fn start(&mut self) -> Result<(), Error>
Starts a background task that periodically refreshes all registered namespace caches.
This method spawns an asynchronous task using async_std::task::spawn
on native targets
or wasm_bindgen_futures::spawn_local
on wasm32 targets. The task loops indefinitely
(until stop
is called or the client is dropped) and performs the following actions
in each iteration:
- Iterates through all namespaces currently managed by the client.
- Calls the
refresh
method on each namespace’sCache
instance. - Logs any errors encountered during the refresh process.
- Sleeps for a predefined interval (currently 30 seconds) before the next refresh cycle.
§Returns
Ok(())
if the background task was successfully started.Err(Error::AlreadyRunning)
if the background task is already active.
Sourcepub async fn stop(&mut self)
pub async fn stop(&mut self)
Stops the background cache refresh task.
This method sets the running
flag to false
, signaling the background task
to terminate its refresh loop.
On non-wasm32 targets, it also attempts to explicitly cancel the spawned task
by calling cancel()
on its JoinHandle
if it exists. This helps to ensure
that the task is properly cleaned up. On wasm32 targets, there is no direct
handle to cancel, so setting the running
flag is the primary mechanism for stopping.
Trait Implementations§
Source§impl FromWasmAbi for Client
impl FromWasmAbi for Client
Source§impl IntoWasmAbi for Client
impl IntoWasmAbi for Client
Source§impl LongRefFromWasmAbi for Client
impl LongRefFromWasmAbi for Client
Source§impl OptionFromWasmAbi for Client
impl OptionFromWasmAbi for Client
Source§impl OptionIntoWasmAbi for Client
impl OptionIntoWasmAbi for Client
Source§impl RefFromWasmAbi for Client
impl RefFromWasmAbi for Client
Source§impl RefMutFromWasmAbi for Client
impl RefMutFromWasmAbi for Client
Source§impl TryFromJsValue for Client
impl TryFromJsValue for Client
Source§impl VectorFromWasmAbi for Client
impl VectorFromWasmAbi for Client
Source§impl VectorIntoWasmAbi for Client
impl VectorIntoWasmAbi for Client
impl SupportsConstructor for Client
impl SupportsInstanceProperty for Client
impl SupportsStaticProperty for Client
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
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> 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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
IntoWasmAbi::Abi
Source§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
IntoWasmAbi::into_abi
, except that it may throw and never
return in the case of Err
.