nodedb_client/traits/document.rs
1// SPDX-License-Identifier: Apache-2.0
2
3//! Supporting types for document and collection-lifecycle operations.
4
5use std::sync::Arc;
6
7/// Event passed to `NodeDb::on_collection_purged` handlers.
8///
9/// Emitted on the sync client when Origin pushes a `CollectionPurged`
10/// wire message and on Lite after local hard-delete completes, so
11/// application code can flush UI caches, drop derived indexes, etc.
12/// Handler callsites must not block — the dispatch path is on the
13/// sync client's receive loop.
14#[derive(Debug, Clone)]
15pub struct CollectionPurgedEvent {
16 pub tenant_id: u64,
17 pub name: String,
18 /// WAL LSN at which the purge was applied. Handlers can compare
19 /// this against locally-observed LSNs for resume/replay logic.
20 pub purge_lsn: u64,
21}
22
23/// Handler registered via `NodeDb::on_collection_purged`. Fn-ref
24/// (not FnMut) so the same handler can fire from multiple threads
25/// without interior mutability ceremony at every call site.
26pub type CollectionPurgedHandler = Arc<dyn Fn(CollectionPurgedEvent) + Send + Sync + 'static>;