Core Component. Every component process a set of events it defines itself Its inputs are `Event`s, allowing it to perform work whenever an event is received, outputting `Effect`s each time it is called. # Error and halting states Components in general are expected to be able to handle every input (`Event`) in every state. Invalid inputs are supposed to be discarded, and the machine is expected
| 123 | /// Components place restrictions on reactor events (`REv`s), indicating what kind of effects they |
| 124 | /// need to be able to produce to operate. |
| 125 | pub(crate) trait Component<REv> { |
| 126 | /// Event associated with `Component`. |
| 127 | /// |
| 128 | /// The event type that is handled by the component. |
| 129 | type Event; |
| 130 | |
| 131 | /// Name of the component. |
| 132 | fn name(&self) -> &str; |
| 133 | |
| 134 | /// Activate/deactivate a failpoint. |
| 135 | fn activate_failpoint(&mut self, _activation: &FailpointActivation) { |
| 136 | // Default is to ignore failpoints. |
| 137 | } |
| 138 | |
| 139 | /// Processes an event, outputting zero or more effects. |
| 140 | /// |
| 141 | /// This function must not ever perform any blocking or CPU intensive work, as it is expected |
| 142 | /// to return very quickly -- it will usually be called from an `async` function context. |
| 143 | fn handle_event( |
| 144 | &mut self, |
| 145 | effect_builder: EffectBuilder<REv>, |
| 146 | rng: &mut NodeRng, |
| 147 | event: Self::Event, |
| 148 | ) -> Effects<Self::Event>; |
| 149 | } |
| 150 | |
| 151 | pub(crate) trait InitializedComponent<REv>: Component<REv> { |
| 152 | fn state(&self) -> &ComponentState; |
nothing calls this directly
no outgoing calls
no test coverage detected