pub struct ResourceRequestHandle { /* private fields */ }Expand description
Owned handle for a resource provider request selected for handling.
The handle may be sent to another thread for deferred completion. It is
one-shot: call complete once to provide a response, or close/drop it to
release the provider’s reference without completing.
Implementations§
Source§impl ResourceRequestHandle
impl ResourceRequestHandle
Sourcepub fn complete(&self, response: ResourceResponse) -> Result<()>
pub fn complete(&self, response: ResourceResponse) -> Result<()>
Completes the request. A completion attempt that reaches native code closes this handle, even when native reports a non-OK status; a binding validation failure leaves the handle live so completion can be retried.
A callback that completes inline and then returns
ResourceProviderDecision::PassThrough still reports the native
Handle decision.
Sourcepub fn is_cancelled(&self) -> Result<bool>
pub fn is_cancelled(&self) -> Result<bool>
Reports whether native code has cancelled the request.
Sourcepub fn set_cancel_callback<F>(&self, callback: F) -> Result<()>
pub fn set_cancel_callback<F>(&self, callback: F) -> Result<()>
Registers the callback that runs when MapLibre cancels this request.
A request accepts one registration; a second one reports
ErrorKind::InvalidState. MapLibre
runs the callback at most once, on the thread that discards the request,
and never for a request the provider completed. Registering on a request
MapLibre already cancelled runs the callback before this call returns, as
part of this call: a concurrent close on another thread does not wait
for it. A
panic inside the callback is contained and discarded, because unwinding
into native code is undefined behavior and the cancel path reports no
status.
The callback may complete or close this same request, which is how a
host retires it early: share the handle through Arc<Mutex<Option<_>>>
and take it from inside the callback. It must not use the map or runtime
the request came from. The request owns the callback until it runs or
the request is completed or closed, so a callback that captures its own
handle keeps that handle alive until then: a host that drops such a
handle without completing or closing it leaks the native request.