1use async_trait::async_trait;
2use std::fmt::Debug;
3
4pub trait Event: Send + Sync + Debug {
5 fn id(&self) -> i64;
6 fn event_type(&self) -> &str;
7}
8
9#[async_trait]
10pub trait EventSource: Send + Sync {
11 type Event: Event;
12 type Error: std::error::Error + Send + Sync + 'static;
13
14 async fn connect(&mut self) -> Result<(), Self::Error>;
15 async fn next_event(&mut self) -> Result<Self::Event, Self::Error>;
16 fn is_connected(&self) -> bool;
17 async fn disconnect(&mut self) -> Result<(), Self::Error>;
18}