Skip to main content

HostCall

Struct HostCall 

Source
#[non_exhaustive]
pub struct HostCall { /* private fields */ }
Expand description

A call (host.call(name, data)) or a post (host.post(name, data)) of the app, as the embedding app’s handler gets it. A call is answered once, from any thread; dropped unanswered, it fails in the app.

Implementations§

Source§

impl HostCall

Source

pub fn name(&self) -> &str

Its name.

Source

pub fn data(&self) -> &JsonValue

Its data (null when the app sent none).

Source

pub fn take_data(&mut self) -> JsonValue

Takes its data, leaving null.

Source

pub fn is_post(&self) -> bool

Whether it is a post, whose answer goes nowhere.

Source

pub fn resolve(self, value: JsonValue)

Answers the call: the app’s promise resolves with value.

Source

pub fn reject(self, message: impl Into<String>)

Fails the call: the app’s promise rejects with an Error of message.

Source

pub fn reply(self, result: Result<JsonValue, String>)

Answers the call with result (HostCall::resolve, HostCall::reject).

Source

pub fn into_reply(self) -> Option<HostReply>

The reply alone, to answer from elsewhere (None for a post).

Source

pub fn sender(&self) -> HostSender

Sends events to the app that made this call or post alone, as HostChannel::send does to the running app: for progress while a handler answers over time. Once that app stops, or another app takes the view (a reload), the sender closes: its events go nowhere rather than to the next app, and HostSender::closed resolves so the handler can stop its work. Take it before HostCall::into_reply; it outlives the call.

Trait Implementations§

Source§

impl Debug for HostCall

Source§

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

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

impl Default for HostCall

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Forget for HostCall

§

impl Freeze for HostCall
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze, PhantomData<Value>: Freeze, *const LeafNode<String, Value> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(String, Value)>>: Freeze, *mut Counter<Channel<Message>>: Freeze, *mut Counter<Channel<Message>>: Freeze, *mut Counter<Channel<Message>>: Freeze, *const ArcInner<CallCount> is !null: Freeze, PhantomData<ArcInner<CallCount>>: Freeze, *const ArcInner<Caller> is !null: Freeze, PhantomData<ArcInner<Caller>>: Freeze,

§

impl Move for HostCall

§

impl RefUnwindSafe for HostCall

§

impl Send for HostCall
where RawVecInner: Send, NodeRef<Owned, String, Value, LeafOrInternal>: Send, BoxRaw<(String, Value)>: Send, Sender<Message>: Send, Arc<CallCount>: Send, Arc<Caller>: Send,

§

impl Sync for HostCall
where RawVecInner: Sync, NodeRef<Owned, String, Value, LeafOrInternal>: Sync, BoxRaw<(String, Value)>: Sync, Sender<Message>: Sync, Arc<CallCount>: Sync, Arc<Caller>: Sync,

§

impl Unpin for HostCall
where *const u8 is !null: Unpin, *const LeafNode<String, Value> is !null: Unpin, Box<(String, Value)>: Unpin, *mut Counter<Channel<Message>>: Unpin, *mut Counter<Channel<Message>>: Unpin, *mut Counter<Channel<Message>>: Unpin, Arc<CallCount>: Unpin, Arc<Caller>: Unpin,

§

impl UnsafeUnpin for HostCall
where *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, PhantomData<Value>: UnsafeUnpin, *const LeafNode<String, Value> is !null: UnsafeUnpin, PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin, PhantomData<Box<(String, Value)>>: UnsafeUnpin, *mut Counter<Channel<Message>>: UnsafeUnpin, *mut Counter<Channel<Message>>: UnsafeUnpin, *mut Counter<Channel<Message>>: UnsafeUnpin, *const ArcInner<CallCount> is !null: UnsafeUnpin, PhantomData<ArcInner<CallCount>>: UnsafeUnpin, *const ArcInner<Caller> is !null: UnsafeUnpin, PhantomData<ArcInner<Caller>>: UnsafeUnpin,

§

impl UnwindSafe for HostCall
where RawVecInner: UnwindSafe, BTreeMap<String, Value>: UnwindSafe, Sender<Message>: UnwindSafe, Arc<CallCount>: UnwindSafe, Arc<Caller>: UnwindSafe,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ParallelSend for T

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more