Skip to main content

fmf_contract/
events.rs

1//! Event kinds — FFI callback `FmfEvent.kind` and pipe event-push opcodes
2//! carry the same values (docs/ARCHITECTURE.md Events section).
3
4/// `u32` on the wire and in the FFI POD.
5#[repr(u32)]
6#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub enum EventKind {
8    /// `entries` = scanned count so far.
9    Progress = 1,
10    /// `entries` = total entries of the now-Ready volume.
11    VolumeReady = 2,
12    /// Engine-side 200ms debounce — the only throttle in the pipeline.
13    IndexChanged = 3,
14    /// A full rescan of a volume has begun (snapshot/journal recovery).
15    RescanStarted = 4,
16    /// The volume could not be indexed and is no longer being served.
17    VolumeFailed = 5,
18    /// `entries` = severity ([`SEVERITY_WARN`] etc.); details are pulled
19    /// from the stats JSON (push notification + pull detail).
20    EngineError = 6,
21}
22
23/// Wire/FFI value of [`EventKind::Progress`].
24pub const FMF_EVENT_PROGRESS: u32 = EventKind::Progress as u32;
25/// Wire/FFI value of [`EventKind::VolumeReady`].
26pub const FMF_EVENT_VOLUME_READY: u32 = EventKind::VolumeReady as u32;
27/// Wire/FFI value of [`EventKind::IndexChanged`].
28pub const FMF_EVENT_INDEX_CHANGED: u32 = EventKind::IndexChanged as u32;
29/// Wire/FFI value of [`EventKind::RescanStarted`].
30pub const FMF_EVENT_RESCAN_STARTED: u32 = EventKind::RescanStarted as u32;
31/// Wire/FFI value of [`EventKind::VolumeFailed`].
32pub const FMF_EVENT_VOLUME_FAILED: u32 = EventKind::VolumeFailed as u32;
33/// Wire/FFI value of [`EventKind::EngineError`].
34pub const FMF_EVENT_ENGINE_ERROR: u32 = EventKind::EngineError as u32;
35
36/// Severity values carried in `FmfEvent.entries` for [`EventKind::EngineError`].
37pub const SEVERITY_WARN: u64 = 1;
38/// A recoverable error degraded a path but the engine keeps serving.
39pub const SEVERITY_ERROR: u64 = 2;
40/// A caught panic crossed the FFI boundary (recovered via `catch_unwind`).
41pub const SEVERITY_PANIC: u64 = 3;