#[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
impl HostCall
Sourcepub fn resolve(self, value: JsonValue)
pub fn resolve(self, value: JsonValue)
Answers the call: the app’s promise resolves with value.
Sourcepub fn reject(self, message: impl Into<String>)
pub fn reject(self, message: impl Into<String>)
Fails the call: the app’s promise rejects with an Error of
message.
Sourcepub fn reply(self, result: Result<JsonValue, String>)
pub fn reply(self, result: Result<JsonValue, String>)
Answers the call with result (HostCall::resolve,
HostCall::reject).
Sourcepub fn into_reply(self) -> Option<HostReply>
pub fn into_reply(self) -> Option<HostReply>
The reply alone, to answer from elsewhere (None for a post).
Sourcepub fn sender(&self) -> HostSender
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.