pub trait Component {
Show 26 methods
// Required methods
fn component_id(&self) -> ComponentId;
fn state(&self) -> ComponentState;
fn transition_state(&mut self, trigger: ComponentTrigger) -> Result<()>;
fn register(
&mut self,
trader_id: TraderId,
clock: Rc<RefCell<dyn Clock>>,
cache: Rc<RefCell<Cache>>,
) -> Result<()>;
// Provided methods
fn is_ready(&self) -> bool { ... }
fn not_running(&self) -> bool { ... }
fn is_running(&self) -> bool { ... }
fn is_stopped(&self) -> bool { ... }
fn is_degraded(&self) -> bool { ... }
fn is_faulted(&self) -> bool { ... }
fn is_disposed(&self) -> bool { ... }
fn initialize(&mut self) -> Result<()> { ... }
fn start(&mut self) -> Result<()> { ... }
fn stop(&mut self) -> Result<()> { ... }
fn resume(&mut self) -> Result<()> { ... }
fn degrade(&mut self) -> Result<()> { ... }
fn fault(&mut self) -> Result<()> { ... }
fn reset(&mut self) -> Result<()> { ... }
fn dispose(&mut self) -> Result<()> { ... }
fn on_start(&mut self) -> Result<()> { ... }
fn on_stop(&mut self) -> Result<()> { ... }
fn on_resume(&mut self) -> Result<()> { ... }
fn on_reset(&mut self) -> Result<()> { ... }
fn on_dispose(&mut self) -> Result<()> { ... }
fn on_degrade(&mut self) -> Result<()> { ... }
fn on_fault(&mut self) -> Result<()> { ... }
}
Expand description
Components have state and lifecycle management capabilities.
Required Methods§
Sourcefn component_id(&self) -> ComponentId
fn component_id(&self) -> ComponentId
Returns the unique identifier for this component.
Sourcefn state(&self) -> ComponentState
fn state(&self) -> ComponentState
Returns the current state of the component.
Sourcefn transition_state(&mut self, trigger: ComponentTrigger) -> Result<()>
fn transition_state(&mut self, trigger: ComponentTrigger) -> Result<()>
Transition the component with the state trigger.
§Errors
Returns an error if the trigger
is an invalid transition from the current state.
Provided Methods§
Sourcefn not_running(&self) -> bool
fn not_running(&self) -> bool
Returns whether the component is not running.
Sourcefn is_running(&self) -> bool
fn is_running(&self) -> bool
Returns whether the component is running.
Sourcefn is_stopped(&self) -> bool
fn is_stopped(&self) -> bool
Returns whether the component is stopped.
Sourcefn is_degraded(&self) -> bool
fn is_degraded(&self) -> bool
Returns whether the component has been degraded.
Sourcefn is_faulted(&self) -> bool
fn is_faulted(&self) -> bool
Returns whether the component has been faulted.
Sourcefn is_disposed(&self) -> bool
fn is_disposed(&self) -> bool
Returns whether the component has been disposed.
Sourcefn initialize(&mut self) -> Result<()>
fn initialize(&mut self) -> Result<()>
Sourcefn reset(&mut self) -> Result<()>
fn reset(&mut self) -> Result<()>
Resets the component to its initial state.
§Errors
Returns an error if the component fails to reset.
Sourcefn dispose(&mut self) -> Result<()>
fn dispose(&mut self) -> Result<()>
Disposes of the component, releasing any resources.
§Errors
Returns an error if the component fails to dispose.