pub trait Component {
Show 27 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 release_subscriptions(&mut self) { ... }
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 fault(&mut self) -> Result<()>
fn fault(&mut self) -> Result<()>
Faults the component.
§Errors
Returns an error if the component fails to fault.
§Notes
Subscriptions are released whether or not on_fault succeeds. This applies to faults
initiated through this method; a failed on_dispose reaches Faulted without invoking
on_fault and retains subscriptions until a later retirement.
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.
§Notes
A successful reset releases retained subscriptions so the component can acquire fresh
subscriptions when it next starts. A failing on_reset retains subscriptions and leaves
the component in Resetting.
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.
§Notes
A failing on_dispose moves the component to Faulted and returns the error without
releasing subscriptions. The trader keeps its registry entries, clock, bookkeeping, and
retained Python wrapper, if any, so the failed retirement leaves the component reachable
and can be retried without a partially dismantled registration.
on_fault does not run, since invoking a second user hook immediately after on_dispose
failed can fail again.
Sourcefn release_subscriptions(&mut self)
fn release_subscriptions(&mut self)
Releases the message bus registrations this component installed.
Runs after successful on_reset and on_dispose hooks, after on_fault returns, and during
explicit retirement cleanup. An override must handle every route and be idempotent so a
failed disposal can release its subscriptions during a later retirement.
Sourcefn on_dispose(&mut self) -> Result<()>
fn on_dispose(&mut self) -> Result<()>
Sourcefn on_degrade(&mut self) -> Result<()>
fn on_degrade(&mut self) -> Result<()>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".