pub trait ChatBackend:
ChatStore
+ ChatSpaces
+ SpacePolicy
+ ChatAccessPolicy
+ ChatRestrictions
+ ChatModeration
+ ChatMessageLifecycle
+ ChatEvents
+ ChatSettings
+ ChatResolvers { }Expand description
Storage backend for JMAP Chat method handlers.
Implementors provide the actual data access; the method handler modules in this crate translate between JMAP wire protocol and backend calls.
Read-side operations (get_objects, get_state, get_changes,
query_objects, query_changes) are defined on the JmapBackend
supertrait. Only write operations and type introspection are here.
This trait is not object-safe by design (generic methods). Use
Arc<impl ChatBackend> when sharing across tasks.
§Async vs sync method convention
ChatBackend carves its methods into two groups:
-
Mutation / hot-path hooks are async.
ChatStore::create_object,ChatStore::update_object,ChatStore::destroy_object,ChatSpaces::apply_space_patch,ChatSpaces::apply_space_metadata_patch,ChatMessageLifecycle::expire_message,ChatMessageLifecycle::read_and_burn_message,ChatAccessPolicy::slow_mode_check,ChatSpaces::generate_invite_code,ChatAccessPolicy::is_contact_blocked, andSpacePolicy::may_set_custom_emojiall returnimpl Future + Send. These methods consult per-account state, may issue I/O, and run on the JMAP request hot path; the async signature lets production backends.awaitstorage / cache / policy lookups without runtime-pinning hazards. -
Policy / capability hooks are sync.
ChatStore::supports_type,ChatSettings::limits,ChatSpaces::protect_last_admin, andChatSettings::retains_edit_historyare synchronous methods. These hooks answer deployment-policy or capability questions whose answer SHOULD be derivable from in-process state (a startup-loaded config snapshot, a cached per-account record). The sync shape keeps the trait surface easy to implement for single-process and reference backends, which are the dominant use case for a kit crate.generate_invite_codeis async and fallible instead, because an HSM or KMS entropy source needs I/O and can fail.
The carve-up is intentional and is NOT a “we forgot to async these”
regression. Production backends that need to consult an async
source for any of the four sync hooks have two options: (a)
pre-cache the answer at startup or on a background refresh; or (b)
file a follow-up bead proposing the conversion for that specific
method, with the production constraint documented. Per-method
rustdoc notes (“# Why sync, not async” / “# Fallibility and async — known limitations”) spell out the workaround on each
affected method. Flipping any of the sync hooks to async is a
major-version breaking change for downstream implementors;
converting them all preemptively for hypothetical multi-tenant
SaaS deployments would over-engineer the kit-vs-product posture
described in workspace AGENTS.md.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".