memory only.Expand description
In-memory reference implementation of TasksBackend.
Gated behind feature = "memory". Not production. See memory for
the full module documentation.
In-memory reference implementation of TasksBackend.
§This is a reference implementation, not production
MemoryBackend is intended for three audiences:
- Workspace integration tests — every
tests/*.rsintegration test in this crate exercises method handlers against this backend. - Downstream contributors — a documented, complete, source-readable
implementation of the
TasksBackendtrait to study when writing a real (database-backed) backend. - Examples and smoke tests — boot a real JMAP-for-Tasks dispatcher with one line of code, without standing up a database.
It is not suitable for production: all state is held in HashMaps
behind one jmap_server::ScopedState, persistence is not implemented, and a number
of draft-ietf-jmap-tasks-06 edge cases are simplified (see source
comments). In particular, UTC-time conversion
(compute_utc_times)
inherits the trait’s default (no time-zone conversion), and
update_task_per_user
stores per-user patches on the shared object (single-user backend).
Task/query has no time-zone database and no recurrence engine:
after / before on a task whose timeZone is not the query’s is
unsupportedFilter, and with expandRecurrences a recurring match is
cannotCalculateOccurrences, and a sort by start over tasks in more
than one zone is unsupportedSort (see
query_tasks on MemoryBackend).
§Feature flag and API stability
This module is gated behind feature = "memory" and is not enabled
by default. Its public API stability is opt-in: it may break across
minor versions while the crate is pre-1.0.
§Example
use std::sync::Arc;
use jmap_tasks_server::{memory::MemoryBackend, register_tasks_handlers};
use jmap_server::Dispatcher;
let mut dispatcher: Dispatcher<()> = Dispatcher::new();
register_tasks_handlers(&mut dispatcher, Arc::new(MemoryBackend::new()));§Concurrency
The store is a jmap_server::ScopedState: a std::sync::Mutex behind
a gate that a draft-ietf-jmap-conditional-02 Foo/set scope holds
(MemoryBackend’s ConditionalBackend impl). Async backend methods
take lock().await, which waits while another task’s scope is open;
sync setup and seeding helpers take lock_unscoped(). With no scope
open the gate is free. The await_holding_lock clippy lint is enabled
module-wide and enforces that no lock guard is held across an
.await.
ScopedState takes a poisoned mutex anyway, so a panic while holding
the guard (already a bug in this module) does not panic every later
call; an atomic scope that panicked is rolled back to its snapshot.
The crate’s tests never poison the lock. A production backend should
implement the trait with its own locking
rather than copy this pattern.
§Tracking
Greenfield reference impl per Beads issue JMAP-hwdv (epic) and
JMAP-hwdv.7 (this crate, mirror of canonical JMAP-hwdv.1 in
jmap-mail-server, following the multi-type-store shape established
by jmap-chat-server’s MemoryBackend and the derived-index pattern
pioneered in JMAP-hwdv.5 jmap-calendars-server).
Structs§
- Memory
Backend - A fully in-memory implementation of
TasksBackend. - Memory
Error - Opaque storage-layer error returned by
MemoryBackendoperations.