1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
use std::{fmt::Debug, slice::Iter}; use error::FrameworkError; use util::Version; /// Framework subcomponents. Handles framework initialization (but could /// be used for a lot more). /// /// Components must implement the `PartialOrd` trait, which will be used to /// determine initialization order. pub trait Component: Debug + Send + Sync { /// Name of this component fn name(&self) -> &'static str; /// Version of this component fn version(&self) -> Version; /// Names of the components this components depends on fn dependencies(&self) -> Iter<&'static str> { [].iter() } /// Initialize this component at the time the framework boots fn init(&mut self) -> Result<(), FrameworkError> { Ok(()) } /// Shut down this component when the app shuts down fn shutdown(&self) -> Result<(), FrameworkError> { Ok(()) } }