pub trait SideEffect {
type Api<'registrar>;
// Required method
fn build(self, registrar: SideEffectRegistrar<'_>) -> Self::Api<'_>;
}
Expand description
Represents a side effect that can be utilized within the build function.
The key observation about side effects is that they form a tree, where each side effect:
- Has its own private state (including composing other side effects together)
- Presents some api to the build method, probably including a way to rebuild & update its state
Required Associated Types§
Sourcetype Api<'registrar>
type Api<'registrar>
The type exposed in the capsule build function when this side effect is registered; in other words, this is the api exposed by the side effect.
Often, a side effect’s api is a tuple, containing values like:
- Data and/or state in this side effect
- Function callbacks (perhaps to trigger a rebuild and/or update the side effect state)
- Anything else imaginable!
Required Methods§
Sourcefn build(self, registrar: SideEffectRegistrar<'_>) -> Self::Api<'_>
fn build(self, registrar: SideEffectRegistrar<'_>) -> Self::Api<'_>
Construct this side effect’s Api
via the given SideEffectRegistrar
.
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.