pub enum SystemEffect {
Alert {
title: String,
message: String,
},
HttpGet {
url: String,
headers: HashMap<String, String>,
},
FileRead {
path: String,
},
Cancel {
req_id: u64,
},
ReleaseResource {
resource_id: u64,
},
OpenUrl {
url: String,
in_app: bool,
},
Authenticate {
url: String,
callback_scheme: String,
},
}Expand description
Built-in system effects that every platform executor must handle.
These cover the most common async operations an application needs.
For app-specific effects, use Effect::App with an opaque byte payload.
§Example
fn fetch_data(state: &mut MyState, _action: FetchTodos, ctx: &mut ReducerContext<MyState>) {
ctx.effects.http_get("https://api.example.com/todos")
.on_ok(ctx.effects.bind(TodosLoaded, handle_loaded as fn(&mut MyState, TodosLoaded)));
}Variants§
Alert
Show a native alert dialog with a title and message.
HttpGet
Perform an HTTP GET request.
FileRead
Read a file from the local filesystem.
Cancel
Cancel a previously issued effect by its request id.
ReleaseResource
Release a platform-managed resource.
OpenUrl
Open a URL in the system browser or an in-app browser sheet.
When in_app is true, the URL opens in a Custom Tab /
SFSafariViewController overlay. When false, the URL opens in the
external browser app.
Authenticate
Initiate an OAuth / secure authentication session.
The platform opens the url and listens for a redirect matching
callback_scheme. The redirect URL is delivered as the effect result.
Trait Implementations§
Source§impl Clone for SystemEffect
impl Clone for SystemEffect
Source§fn clone(&self) -> SystemEffect
fn clone(&self) -> SystemEffect
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SystemEffect
impl Debug for SystemEffect
Source§impl<'de> Deserialize<'de> for SystemEffect
impl<'de> Deserialize<'de> for SystemEffect
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for SystemEffect
impl PartialEq for SystemEffect
Source§impl Serialize for SystemEffect
impl Serialize for SystemEffect
impl Eq for SystemEffect
impl StructuralPartialEq for SystemEffect
Auto Trait Implementations§
impl Freeze for SystemEffect
impl RefUnwindSafe for SystemEffect
impl Send for SystemEffect
impl Sync for SystemEffect
impl Unpin for SystemEffect
impl UnsafeUnpin for SystemEffect
impl UnwindSafe for SystemEffect
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.