pub trait ConditionalBackend: JmapBackend {
// Required method
fn begin_set(
&self,
caller: &Self::CallerCtx,
request: SetScopeRequest<'_>,
) -> impl Future<Output = Result<Box<dyn SetScope>, BeginSetError<Self::Error>>> + Send;
// Provided method
fn hidden_properties(
&self,
caller: &Self::CallerCtx,
account_id: Option<&Id>,
data_type: &str,
ids: &[Id],
) -> impl Future<Output = Result<BTreeMap<Id, Vec<String>>, Self::Error>> + Send { ... }
}Expand description
The conditional-02 backend hooks, required only by the opt-in
register_<x>_conditional fns (decision 1).
Like PushSubscriptionBackend, a
separate trait over JmapBackend, so a backend that does not opt in
is untouched.
Required Methods§
Sourcefn begin_set(
&self,
caller: &Self::CallerCtx,
request: SetScopeRequest<'_>,
) -> impl Future<Output = Result<Box<dyn SetScope>, BeginSetError<Self::Error>>> + Send
fn begin_set( &self, caller: &Self::CallerCtx, request: SetScopeRequest<'_>, ) -> impl Future<Output = Result<Box<dyn SetScope>, BeginSetError<Self::Error>>> + Send
Open the scope one Foo/set method call runs in (§4, §6.1).
Lock, or start a transaction over, everything the method may read
or write in request.account_id, across all types: cascades (a
Mailbox destroy’s onDestroyRemoveEmails, EmailSubmission’s
implicit Email/set) run inside it. Every backend call made while
current_set_scope is Some(request.scope) belongs to the scope,
and get_state inside it sees the scope’s writes.
SetMode::Isolated: no other writer commits to the account between the precondition reads and the method’s writes (§6.1).SetMode::Atomicadditionally: check cross-object constraints atSetScope::commitagainst the final state, leave the state string and change log unchanged on rollback (§4.2), and defer irreversible external effects to commit, or refuse withBeginSetError::CannotApplyAtomically(§4.3). Object-history restores in the scope are part of the unit.
A backend MAY refuse large methods (§9.2).
No default: a scope that does nothing lets a concurrent write land
between check and apply, so the server would report success for a
write §3.2 requires to be stateMismatch. A backend that already
serializes every write per account can return
serialized_writes_scope.
§Errors
BeginSetError::CannotApplyAtomically or a storage error.
Provided Methods§
For each of ids (objects of data_type in account_id), the
top-level properties caller may not read, beyond what Foo/get
already leaves out or blanks for them (§9.1).
A precondition on such a property is answered forbidden without
comparing its value, so the answer never depends on data the caller
cannot see.
Default: nothing hidden (a permission hook, fail-open like the other permission hooks, bd JMAP-bghk). Override it when the backend’s Foo/get redacts a property per caller.
§Errors
A storage error; the method fails with a redacted serverFail.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".