Skip to main content

ResourceRequestHandle

Struct ResourceRequestHandle 

Source
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

Source

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.

Source

pub fn is_cancelled(&self) -> Result<bool>

Reports whether native code has cancelled the request.

Source

pub fn set_cancel_callback<F>(&self, callback: F) -> Result<()>
where F: FnOnce() + Send + 'static,

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.

Source

pub fn close(self)

Releases the provider-owned request handle without completing it. Releasing waits for a cancel callback running on another thread, and returns without waiting from inside that callback.

Trait Implementations§

Source§

impl Debug for ResourceRequestHandle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for ResourceRequestHandle

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.