use alloc::boxed::Box;
use crate::event::{EventType, StructuredEvent};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Disconnected;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ConnectError {
AlreadyConnected,
TypeError,
}
pub trait StructuredPushConsumer: Send + Sync {
fn push_structured_event(&self, event: StructuredEvent) -> Result<(), Disconnected>;
fn disconnect(&self);
}
pub trait StructuredPushSupplier: Send + Sync {
fn disconnect(&self);
}
pub trait StructuredPullConsumer: Send + Sync {
fn disconnect(&self);
}
pub trait StructuredPullSupplier: Send + Sync {
fn pull_structured_event(&self) -> Result<StructuredEvent, Disconnected>;
fn try_pull_structured_event(&self) -> Result<(StructuredEvent, bool), Disconnected>;
fn disconnect(&self);
}
pub trait NotifyPublish: Send + Sync {
fn offer_change(&self, added: &[EventType], removed: &[EventType]);
}
pub trait NotifySubscribe: Send + Sync {
fn subscription_change(&self, added: &[EventType], removed: &[EventType]);
}
pub type BoxedPushConsumer = Box<dyn StructuredPushConsumer>;
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn connect_error_variants_distinct() {
assert_ne!(ConnectError::AlreadyConnected, ConnectError::TypeError);
}
}