Trait Component

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

Source

fn id(&self) -> ComponentId

Returns the unique identifier for this component.

Source

fn state(&self) -> ComponentState

Returns the current state of the component.

Source

fn trigger(&self) -> ComponentTrigger

Returns the component trigger.

Source

fn is_running(&self) -> bool

Returns whether the component is currently running.

Source

fn is_stopped(&self) -> bool

Returns whether the component is stopped.

Source

fn is_disposed(&self) -> bool

Returns whether the component has been disposed.

Source

fn start(&mut self) -> Result<()>

Starts the component.

§Errors

Returns an error if the component fails to start.

Source

fn stop(&mut self) -> Result<()>

Stops the component.

§Errors

Returns an error if the component fails to stop.

Source

fn reset(&mut self) -> Result<()>

Resets the component to its initial state.

§Errors

Returns an error if the component fails to reset.

Source

fn dispose(&mut self) -> Result<()>

Disposes of the component, releasing any resources.

§Errors

Returns an error if the component fails to dispose.

Source

fn handle_event(&mut self, event: TimeEvent)

Handles a timer event (TBD).

Implementors§