pub trait Component: Debug {
// Required methods
fn id(&self) -> ComponentId;
fn state(&self) -> ComponentState;
fn trigger(&self) -> ComponentTrigger;
fn is_running(&self) -> bool;
fn is_stopped(&self) -> bool;
fn is_disposed(&self) -> bool;
fn start(&mut self) -> Result<()>;
fn stop(&mut self) -> Result<()>;
fn reset(&mut self) -> Result<()>;
fn dispose(&mut self) -> Result<()>;
fn handle_event(&mut self, event: TimeEvent);
}
Expand description
Common trait for components.
Required Methods§
Sourcefn state(&self) -> ComponentState
fn state(&self) -> ComponentState
Returns the current state of the component.
Sourcefn trigger(&self) -> ComponentTrigger
fn trigger(&self) -> ComponentTrigger
Returns the component trigger.
Sourcefn is_running(&self) -> bool
fn is_running(&self) -> bool
Returns whether the component is currently running.
Sourcefn is_stopped(&self) -> bool
fn is_stopped(&self) -> bool
Returns whether the component is stopped.
Sourcefn is_disposed(&self) -> bool
fn is_disposed(&self) -> bool
Returns whether the component has been disposed.
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.
Sourcefn handle_event(&mut self, event: TimeEvent)
fn handle_event(&mut self, event: TimeEvent)
Handles a timer event (TBD).