use std::hash::Hash;
use std::sync::Arc;
use serde::de::DeserializeOwned;
use serde::Serialize;
use super::Subscriber;
#[async_trait::async_trait]
pub trait Spec: Send + Sync {
type Topic: Send
+ Sync
+ Clone
+ Eq
+ PartialEq
+ Ord
+ PartialOrd
+ Hash
+ Send
+ Sync
+ DeserializeOwned
+ Serialize;
type Event: Event<Topic = Self::Topic>
+ Send
+ Sync
+ Eq
+ PartialEq
+ DeserializeOwned
+ Serialize;
type SubscriptionId: Clone
+ Default
+ Eq
+ PartialEq
+ Ord
+ PartialOrd
+ Hash
+ Send
+ Sync
+ DeserializeOwned
+ Serialize;
type Context;
fn new_instance(context: Self::Context) -> Arc<Self>
where
Self: Sized;
async fn fetch_events(
self: &Arc<Self>,
topics: Vec<<Self::Event as Event>::Topic>,
reply_to: Subscriber<Self>,
) where
Self: Sized;
}
pub trait Event: Clone + Send + Sync + Eq + PartialEq + DeserializeOwned + Serialize {
type Topic;
fn get_topics(&self) -> Vec<Self::Topic>;
}