use tracing::debug;
use crate::*;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SubscriptionUpdate {
Skip,
Read,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SubscriptionErrorAction {
Continue,
Stop,
}
pub trait SubscriptionDef<
B: BlockDef + Send + 'static,
BR: BlockReferredDef<B> + 'static,
P: PayloadDef<Inner> + Send + 'static,
Inner: PayloadInnerDef + Send + 'static,
O: Send + Sync + 'static,
>: Send
{
fn on_update(&mut self, total: usize, added: usize) -> SubscriptionUpdate;
#[allow(unused)]
fn on_packet(&mut self, packet: PacketDef<B, P, Inner>) {
let _ = packet;
}
fn on_error(&mut self, err: &Error) -> SubscriptionErrorAction {
debug!("Error on reading data with observer: {err}");
SubscriptionErrorAction::Continue
}
fn on_stopped(&mut self, reason: Option<Error>) {
let _ = reason;
}
fn on_aborted(&mut self) {
}
}