bb_runtime/errors/snapshot.rs
1//! `SnapshotError` — failures `Node::snapshot()` can surface.
2//!
3//! Snapshot capture refuses to proceed when the in-Node typed bus
4//! still holds events that a restore would silently drop or re-fire
5//! against stale state. Drain the bus by polling to quiescence
6//! before retrying snapshot.
7
8/// Failures `Node::snapshot()` returns instead of panicking.
9#[derive(Debug)]
10pub enum SnapshotError {
11 /// The in-Node typed bus still carries un-drained events at the
12 /// moment `snapshot()` is invoked. A restore would either
13 /// silently drop them or re-fire stale infra events — neither
14 /// preserves Node fidelity. Callers drive `Node::poll` until the
15 /// bus is empty before retrying.
16 BusNotDrained {
17 /// Events still queued at snapshot time.
18 queued: usize,
19 /// FIFO-dropped events accumulated since the last drain.
20 dropped: usize,
21 },
22}
23
24impl std::fmt::Display for SnapshotError {
25 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
26 match self {
27 Self::BusNotDrained { queued, dropped } => write!(
28 f,
29 "bus not drained at snapshot time: queued={queued} dropped={dropped}",
30 ),
31 }
32 }
33}
34
35impl std::error::Error for SnapshotError {}