pub struct Cx<E> { /* private fields */ }Expand description
Effects an app requests during update, generic over the app event type so
continuations stay fully typed.
Implementations§
Source§impl<E> Cx<E>
impl<E> Cx<E>
Sourcepub fn notify(
&mut self,
plugin: impl Into<String>,
op: impl Into<String>,
input: impl Into<String>,
)
pub fn notify( &mut self, plugin: impl Into<String>, op: impl Into<String>, input: impl Into<String>, )
Fire-and-forget call to a native plugin.
Sourcepub fn plugin(
&mut self,
plugin: impl Into<String>,
op: impl Into<String>,
input: impl Into<String>,
then: impl FnOnce(PluginResponse) -> E + Send + 'static,
)
pub fn plugin( &mut self, plugin: impl Into<String>, op: impl Into<String>, input: impl Into<String>, then: impl FnOnce(PluginResponse) -> E + Send + 'static, )
Request/response call: when the plugin replies, then(response) produces
the typed event delivered back to your update.
Sourcepub fn save(&mut self, data: impl Into<String>)
pub fn save(&mut self, data: impl Into<String>)
Persist data (handed back to MobilerApp::restore on next startup).
Sourcepub fn copy(&mut self, text: impl Into<String>)
pub fn copy(&mut self, text: impl Into<String>)
Copy text to the system clipboard (built-in clipboard capability).
Open the system share sheet with text (built-in share capability).
Sourcepub fn open_url(&mut self, url: impl Into<String>)
pub fn open_url(&mut self, url: impl Into<String>)
Open url in the platform browser / default handler (built-in browser
capability). Fire-and-forget: the app leaves the foreground.
Sourcepub fn toast(&mut self, text: impl Into<String>)
pub fn toast(&mut self, text: impl Into<String>)
Show a transient toast / snackbar with text (built-in toast capability).
Sourcepub fn haptic(&mut self, style: impl Into<String>)
pub fn haptic(&mut self, style: impl Into<String>)
Fire a haptic tap (built-in haptics capability). style is "light",
"medium", or "heavy"; unknown styles fall back to medium.
Sourcepub fn http(
&mut self,
method: impl Into<String>,
url: impl Into<String>,
body: Option<String>,
then: impl FnOnce(PluginResponse) -> E + Send + 'static,
)
pub fn http( &mut self, method: impl Into<String>, url: impl Into<String>, body: Option<String>, then: impl FnOnce(PluginResponse) -> E + Send + 'static, )
Perform an HTTP request via the shell’s built-in http capability. When it
completes, then(response) produces the typed event delivered back to
update — response.output is the body, response.ok is success (2xx).
Rides the request/response plugin mechanism, so it resolves asynchronously.
Sourcepub fn get(
&mut self,
url: impl Into<String>,
then: impl FnOnce(PluginResponse) -> E + Send + 'static,
)
pub fn get( &mut self, url: impl Into<String>, then: impl FnOnce(PluginResponse) -> E + Send + 'static, )
GET url, delivering the response to then.
Sourcepub fn post(
&mut self,
url: impl Into<String>,
body: impl Into<String>,
then: impl FnOnce(PluginResponse) -> E + Send + 'static,
)
pub fn post( &mut self, url: impl Into<String>, body: impl Into<String>, then: impl FnOnce(PluginResponse) -> E + Send + 'static, )
POST url with a JSON body, delivering the response to then.
Sourcepub fn patch(
&mut self,
url: impl Into<String>,
body: impl Into<String>,
then: impl FnOnce(PluginResponse) -> E + Send + 'static,
)
pub fn patch( &mut self, url: impl Into<String>, body: impl Into<String>, then: impl FnOnce(PluginResponse) -> E + Send + 'static, )
PATCH url with a JSON body, delivering the response to then.
Sourcepub fn delete(
&mut self,
url: impl Into<String>,
then: impl FnOnce(PluginResponse) -> E + Send + 'static,
)
pub fn delete( &mut self, url: impl Into<String>, then: impl FnOnce(PluginResponse) -> E + Send + 'static, )
DELETE url, delivering the response to then.
Sourcepub fn device_model(
&mut self,
then: impl FnOnce(PluginResponse) -> E + Send + 'static,
)
pub fn device_model( &mut self, then: impl FnOnce(PluginResponse) -> E + Send + 'static, )
Query the device model/name via the built-in device capability; the result
(response.output, e.g. “Google Pixel 7” / “Apple iPhone (iOS 18.0)”) is
delivered to then.
Sourcepub fn confirm(
&mut self,
title: impl Into<String>,
message: impl Into<String>,
then: impl FnOnce(PluginResponse) -> E + Send + 'static,
)
pub fn confirm( &mut self, title: impl Into<String>, message: impl Into<String>, then: impl FnOnce(PluginResponse) -> E + Send + 'static, )
Ask the user to confirm via a native dialog (built-in dialog capability).
then receives the choice: response.ok is true if confirmed, false if
cancelled/dismissed. Resolves asynchronously (the user replies whenever).