diff options
-rw-r--r-- | src/component.rs | 10 | ||||
-rw-r--r-- | src/main.rs | 2 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/component.rs b/src/component.rs index 32dab6d..6706268 100644 --- a/src/component.rs +++ b/src/component.rs @@ -39,7 +39,9 @@ pub trait Component: Send + 'static { type Updater: Update; type Colorer: Update; type Handler: Button; +} +pub trait Runner: Component + private::Sealed { fn run<R: Read + Send>(reader: R) -> impl Future<Output = Result<(), Error>> + Send { async move { use std::io::BufRead; @@ -139,6 +141,14 @@ pub trait Component: Send + 'static { } } +impl<T: Component> Runner for T {} + +mod private { + pub trait Sealed {} + + impl<T: super::Component> Sealed for T {} +} + pub trait Update: Send + 'static { type Value: Send; diff --git a/src/main.rs b/src/main.rs index 3b6ed8b..aa74e09 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -use i3blocks::component::{Component, Icon, Next, Play, Prev, Title, Volume}; +use i3blocks::component::{Icon, Next, Play, Prev, Runner, Title, Volume}; #[tokio::main] async fn main() -> Result<(), main_error::MainError> { |