its getting cleaner

This commit is contained in:
Ferdinand Schober
2024-07-10 20:31:02 +02:00
parent 89ca9c3c0b
commit 8ba92ede34
9 changed files with 413 additions and 282 deletions

View File

@@ -1,5 +1,6 @@
use std::{fmt::Display, io};
use async_trait::async_trait;
use futures_core::Stream;
use input_event::Event;
@@ -92,17 +93,21 @@ impl Display for Backend {
}
}
#[async_trait]
pub trait InputCapture:
Stream<Item = Result<(CaptureHandle, Event), CaptureError>> + Unpin
{
/// create a new client with the given id
fn create(&mut self, id: CaptureHandle, pos: Position) -> io::Result<()>;
async fn create(&mut self, id: CaptureHandle, pos: Position) -> io::Result<()>;
/// destroy the client with the given id, if it exists
fn destroy(&mut self, id: CaptureHandle) -> io::Result<()>;
async fn destroy(&mut self, id: CaptureHandle) -> io::Result<()>;
/// release mouse
fn release(&mut self) -> io::Result<()>;
async fn release(&mut self) -> io::Result<()>;
/// destroy the input acpture
async fn async_drop(&mut self) -> Result<(), CaptureError>;
}
pub async fn create_backend(