pub trait Action:
Serialize
+ DeserializeOwned
+ Any
+ Send
+ Sync
+ Debug {
// Required method
fn static_id() -> ActionId
where Self: Sized;
// Provided method
fn encode(&self) -> Vec<u8> ⓘ { ... }
}Expand description
A strongly-typed, serialisable event payload.
Every action type must be Serialize + DeserializeOwned + Send + Sync + Debug
and provide a stable ActionId via Action::static_id. The runtime
uses JSON serialisation internally, so actions travel across the
widget/reducer boundary without generics.
§Implementing Action
ⓘ
use fission_core::{Action, ActionId};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
struct SetName { name: String }
impl Action for SetName {
fn static_id() -> ActionId {
ActionId::from_name("my_app::SetName")
}
}Required Methods§
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.