#[non_exhaustive]pub struct SetResponse<T> {
pub account_id: Id,
pub old_state: Option<State>,
pub new_state: State,
pub created: BTreeMap<String, T>,
pub updated: BTreeMap<Id, Option<T>>,
pub destroyed: Vec<Id>,
pub not_created: BTreeMap<String, SetError>,
pub not_updated: BTreeMap<Id, SetError>,
pub not_destroyed: BTreeMap<Id, SetError>,
pub extra: Map<String, Value>,
}Expand description
RFC 8620 §5.3 — Foo/set response shape.
Wire shape per RFC 8620 §5.3 (rfc8620.txt §5.3 around line 2033):
created Id[Foo] | null
updated Id[Foo|null] | null ← inner null is REQUIRED
destroyed Id[] | null
notCreated Id[SetError] | null
notUpdated Id[SetError] | null
notDestroyed Id[SetError] | nullThe inner null in updated is the server’s signal that the patch was
applied verbatim with no server-set property deltas to report; a typed
SetResponse<Foo> MUST accept this rather than failing because null
cannot become Foo.
created and not_created keys are caller-supplied creation ids
(String); updated, not_updated, not_destroyed keys are
server-assigned record ids (Id) — typed differently so callers can
use updated/destroyed keys interchangeably with ids from any
/get response.
The result maps and lists are plain collections, not Options: RFC 8620
defines each as “null if none”, so an empty collection means none. A
null or absent field decodes as empty and an empty one encodes as
null.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.account_id: IdThe account the response refers to.
old_state: Option<State>State token before this /set was applied. RFC 8620 §5.3 makes the
property String|null; None when it is null or, from a server
that leaves it out, absent.
new_state: StateState token after this /set.
RFC 8620 §5.3 requires newState, but some servers leave it out
(Stalwart 1.1.1 does when a /set changes nothing). Such a response
still deserializes, with new_state set to the empty state
(""), so that its created / updated / destroyed / not*
results are not lost (docs/design/DECISIONS.md decision 67).
jmap-base-client’s extract_response logs a warn event when
it decodes such a response.
An empty new_state is not a real state: do not store it or pass
it as sinceState or ifInState. A Foo/changes from it fails
(typically cannotCalculateChanges). Re-fetch the current state
with Foo/get instead. Serializing such a response writes
"newState": "". This placeholder is a recorded exception to the
workspace rule against in-band sentinels (decision 72), kept so that
tolerating such servers is not an API break.
created: BTreeMap<String, T>Successfully created objects, keyed by caller-supplied creation id.
updated: BTreeMap<Id, Option<T>>Successfully updated objects, keyed by record id. The value is
Some(T) when the server reports server-set property deltas, or
None when the patch was applied verbatim with nothing to echo.
destroyed: Vec<Id>Ids of successfully destroyed objects.
not_created: BTreeMap<String, SetError>Failed creates, keyed by caller-supplied creation id.
not_updated: BTreeMap<Id, SetError>Failed updates, keyed by record id.
not_destroyed: BTreeMap<Id, SetError>Failed destroys, keyed by record id.
extra: Map<String, Value>Catch-all for vendor / site / private extension fields not covered by the typed fields above. Preserves unknown fields across deserialize/serialize round-trip per workspace extras-preservation policy (see workspace AGENTS.md).