Skip to main content

Cx

Struct Cx 

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

Source

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.

Source

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.

Source

pub fn save(&mut self, data: impl Into<String>)

Persist data (handed back to MobilerApp::restore on next startup).

Source

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 updateresponse.output is the body, response.ok is success (2xx). Rides the request/response plugin mechanism, so it resolves asynchronously.

Source

pub fn get( &mut self, url: impl Into<String>, then: impl FnOnce(PluginResponse) -> E + Send + 'static, )

GET url, delivering the response to then.

Source

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.

Source

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.

Source

pub fn delete( &mut self, url: impl Into<String>, then: impl FnOnce(PluginResponse) -> E + Send + 'static, )

DELETE url, delivering the response to then.

Trait Implementations§

Source§

impl<E> Default for Cx<E>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<E> Freeze for Cx<E>

§

impl<E> !RefUnwindSafe for Cx<E>

§

impl<E> Send for Cx<E>

§

impl<E> !Sync for Cx<E>

§

impl<E> Unpin for Cx<E>

§

impl<E> UnsafeUnpin for Cx<E>

§

impl<E> !UnwindSafe for Cx<E>

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.