Expand description
Mem-change events: runtime-agnostic callback-based subscribe API.
Every successful write mutation (memstead_create, memstead_update,
memstead_delete, memstead_relate, memstead_rename) emits a
MemChangedEvent after update-ref lands. Consumers register
a callback per mem via [Engine::subscribe_mem_changes] and
receive an event on every commit.
The Core (this module + the Engine wiring) is std-only: no
tokio, no notify, no async runtime dependency. Tokio-broadcast and
filesystem-watcher conveniences live behind opt-in feature flags
(tokio, file-watcher) so UniFFI / WASM / sync consumers are not
forced to drag async runtimes into their dependency graph.
Consumer-side contract: transport / routing / filtering are not the engine’s job — it only emits the events.
Structs§
- MemChanged
Event - Event payload emitted on every committed mutation.
- Subscription
Handle - RAII handle returned by [
Engine::subscribe_mem_changes]. Holds the consumer’s subscription id and a back-reference to the engine’s shared registry. OnDrop(or via the explicitSelf::unsubscribeconsumer) the slot is removed from the registry — subsequent events to that mem skip the callback.
Constants§
- DEFAULT_
BROADCAST_ CAPACITY - Default capacity for the tokio broadcast channel returned by
[
Engine::subscribe_mem_changes_broadcast]. Sized so a typical burst (one mutation per few ms; subscriber polling at frame / HTTP-request granularity) does not trip the lagged-error path, while keeping memory bounded for many subscribers.
Type Aliases§
- Event
Callback - Type alias for the callback shape consumers register.
Arc<dyn Fn>keeps the subscriber’s closure cheaply cloneable so the emit path can snapshot the list, release the registry lock, and call into callbacks without re-entering the engine’s mutex.