use serde::{Serialize, de::DeserializeOwned};
use crate::event::scope::EventScope;
use crate::queue::QueuePolicy;
pub trait Message: Serialize + DeserializeOwned + Clone + Send + Sync + 'static {
fn message_type() -> &'static str
where
Self: Sized;
fn source() -> &'static str
where
Self: Sized;
fn scope() -> EventScope
where
Self: Sized;
fn subject(&self) -> Option<String> {
None
}
}
pub trait RequestMessage: Message {
type Response: Message;
}
pub trait CommandMessage: RequestMessage {}
pub trait QueryMessage: RequestMessage {}
pub trait QueuedCommand: CommandMessage {
fn queue_policy() -> QueuePolicy
where
Self: Sized;
}
pub trait DomainEvent: Message {}