From 1aee2ab4b747bcae93d16f5e4437909cac897080 Mon Sep 17 00:00:00 2001 From: Toby Vincent Date: Sat, 20 Jul 2024 15:20:05 -0500 Subject: feat!: move runner functions to sealed trait --- src/component.rs | 10 ++++++++++ src/main.rs | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) 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(reader: R) -> impl Future> + Send { async move { use std::io::BufRead; @@ -139,6 +141,14 @@ pub trait Component: Send + 'static { } } +impl Runner for T {} + +mod private { + pub trait Sealed {} + + impl 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> { -- cgit v1.2.3-70-g09d2