Trait SideEffect

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

Source

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§

Source

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.

Implementations on Foreign Types§

Source§

impl SideEffect for ()

Source§

type Api<'registrar> = ()

Source§

fn build(self, registrar: SideEffectRegistrar<'_>) -> Self::Api<'_>

Source§

impl<A: SideEffect, B: SideEffect> SideEffect for (A, B)

Source§

type Api<'registrar> = (<A as SideEffect>::Api<'registrar>, <B as SideEffect>::Api<'registrar>)

Source§

fn build(self, registrar: SideEffectRegistrar<'_>) -> Self::Api<'_>

Source§

impl<A: SideEffect, B: SideEffect, C: SideEffect> SideEffect for (A, B, C)

Source§

type Api<'registrar> = (<A as SideEffect>::Api<'registrar>, <B as SideEffect>::Api<'registrar>, <C as SideEffect>::Api<'registrar>)

Source§

fn build(self, registrar: SideEffectRegistrar<'_>) -> Self::Api<'_>

Source§

impl<A: SideEffect, B: SideEffect, C: SideEffect, D: SideEffect> SideEffect for (A, B, C, D)

Source§

type Api<'registrar> = (<A as SideEffect>::Api<'registrar>, <B as SideEffect>::Api<'registrar>, <C as SideEffect>::Api<'registrar>, <D as SideEffect>::Api<'registrar>)

Source§

fn build(self, registrar: SideEffectRegistrar<'_>) -> Self::Api<'_>

Source§

impl<A: SideEffect, B: SideEffect, C: SideEffect, D: SideEffect, E: SideEffect> SideEffect for (A, B, C, D, E)

Source§

type Api<'registrar> = (<A as SideEffect>::Api<'registrar>, <B as SideEffect>::Api<'registrar>, <C as SideEffect>::Api<'registrar>, <D as SideEffect>::Api<'registrar>, <E as SideEffect>::Api<'registrar>)

Source§

fn build(self, registrar: SideEffectRegistrar<'_>) -> Self::Api<'_>

Source§

impl<A: SideEffect, B: SideEffect, C: SideEffect, D: SideEffect, E: SideEffect, F: SideEffect> SideEffect for (A, B, C, D, E, F)

Source§

type Api<'registrar> = (<A as SideEffect>::Api<'registrar>, <B as SideEffect>::Api<'registrar>, <C as SideEffect>::Api<'registrar>, <D as SideEffect>::Api<'registrar>, <E as SideEffect>::Api<'registrar>, <F as SideEffect>::Api<'registrar>)

Source§

fn build(self, registrar: SideEffectRegistrar<'_>) -> Self::Api<'_>

Source§

impl<A: SideEffect, B: SideEffect, C: SideEffect, D: SideEffect, E: SideEffect, F: SideEffect, G: SideEffect> SideEffect for (A, B, C, D, E, F, G)

Source§

type Api<'registrar> = (<A as SideEffect>::Api<'registrar>, <B as SideEffect>::Api<'registrar>, <C as SideEffect>::Api<'registrar>, <D as SideEffect>::Api<'registrar>, <E as SideEffect>::Api<'registrar>, <F as SideEffect>::Api<'registrar>, <G as SideEffect>::Api<'registrar>)

Source§

fn build(self, registrar: SideEffectRegistrar<'_>) -> Self::Api<'_>

Source§

impl<A: SideEffect, B: SideEffect, C: SideEffect, D: SideEffect, E: SideEffect, F: SideEffect, G: SideEffect, H: SideEffect> SideEffect for (A, B, C, D, E, F, G, H)

Source§

type Api<'registrar> = (<A as SideEffect>::Api<'registrar>, <B as SideEffect>::Api<'registrar>, <C as SideEffect>::Api<'registrar>, <D as SideEffect>::Api<'registrar>, <E as SideEffect>::Api<'registrar>, <F as SideEffect>::Api<'registrar>, <G as SideEffect>::Api<'registrar>, <H as SideEffect>::Api<'registrar>)

Source§

fn build(self, registrar: SideEffectRegistrar<'_>) -> Self::Api<'_>

Implementors§

Source§

impl<T, F: FnOnce(SideEffectRegistrar<'_>) -> T> SideEffect for F

Source§

type Api<'registrar> = T