1use std::future::Future;
2use std::pin::Pin;
3
4use tea_protocol::{EventEnvelope, SessionId, SessionSequence};
5
6use crate::KernelError;
7
8pub type KernelEventFuture<'a> = Pin<Box<dyn Future<Output = Result<(), KernelError>> + Send + 'a>>;
10
11pub trait KernelEventSink: std::fmt::Debug + Send + Sync {
13 fn last_sequence(&self, _session_id: SessionId) -> Option<SessionSequence> {
18 None
19 }
20
21 fn emit(&self, event: EventEnvelope) -> KernelEventFuture<'_>;
23}
24
25#[derive(Debug, Clone, Copy, Default)]
27pub struct DiscardEventSink;
28
29impl KernelEventSink for DiscardEventSink {
30 fn emit(&self, _event: EventEnvelope) -> KernelEventFuture<'_> {
31 Box::pin(async { Ok(()) })
32 }
33}