Skip to main content

SnapshotFetcher

Type Alias SnapshotFetcher 

Source
pub type SnapshotFetcher = Arc<dyn Fn(&AuthContext, &str, &str) -> Option<Vec<u8>> + Send + Sync>;
Expand description

Snapshot fetcher: given the caller’s auth context + (entity, row_id), return the encoded binary CRDT frame for the row’s current state, or None if either the caller can’t read the row (read policy denies) or the row has no snapshot (uninitialized CRDT or non-CRDT entity).

Auth context is passed in (rather than checked at the WS layer) because the policy engine + DataStore handles live in the runtime crate. Without this check an authenticated client could subscribe to any (entity, row_id) and receive every binary CRDT frame even for rows their query policy would reject — a silent read- policy bypass.

Wrapped in an Arc so the runtime can build it once, capturing the LoroStore + PolicyEngine handles, and hand the same closure to every accepted connection.

Aliased Type§

pub struct SnapshotFetcher { /* private fields */ }