summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorToby Vincent <tobyv@tobyvin.dev>2024-07-20 15:20:05 -0500
committerToby Vincent <tobyv@tobyvin.dev>2024-07-20 15:20:05 -0500
commit1aee2ab4b747bcae93d16f5e4437909cac897080 (patch)
tree48d4037418479a4241545b1ab0c6f926ec410259
parent5b46ff1843bbed0ff1e167928d7f2b3b9968a918 (diff)
feat!: move runner functions to sealed trait
-rw-r--r--src/component.rs10
-rw-r--r--src/main.rs2
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> {