#[non_exhaustive]pub struct SetError {
pub error_type: String,
pub description: Option<String>,
pub properties: Option<Vec<String>>,
pub existing_id: Option<Id>,
pub not_found: Option<Vec<Id>>,
pub max_recipients: Option<u64>,
pub invalid_recipients: Option<Vec<String>>,
pub max_size: Option<u64>,
pub extra: Map<String, Value>,
}Expand description
A per-item failure in a /set response (RFC 8620 §5.3).
Appears as the value type in the notCreated, notUpdated, and
notDestroyed maps of SetResponse. The error_type field uses
String rather than a typed enum so extension errors (e.g.
"calendarHasEvent", "noSupportedScheduleMethods") round-trip
cleanly without requiring a version-bump on every new spec extension.
All fields beyond error_type are optional and present only when the
corresponding error type calls for them per RFC 8620 §5.3 / RFC 8621
§5.5, §5.7, §7.5:
| Field | Set when error_type is | Spec |
|---|---|---|
description | any (optional human-readable detail) | RFC 8620 §5.3 |
properties | invalidProperties | RFC 8620 §5.3 |
existing_id | alreadyExists | RFC 8620 §5.4, RFC 8621 §5.7 |
not_found | blobNotFound | RFC 8621 §5.5 |
max_recipients | tooManyRecipients | RFC 8621 §7.5 |
invalid_recipients | invalidRecipients | RFC 8621 §7.5 |
max_size | tooLarge | RFC 8621 §7.5 |
§Extension fields
JMAP extensions (e.g. JMAP Chat’s serverRetryAfter for slow-mode
rate limiting) MAY add additional SetError fields beyond the RFC 8620
base set. The extra field captures any such field via
#[serde(flatten)] so it round-trips losslessly. Extension crates
(e.g. jmap-chat-client) provide typed accessor helpers that read
from extra — the base type stays free of extension-specific fields.
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.error_type: StringThe machine-readable error type (e.g. "forbidden", "notFound",
"alreadyExists", or an extension-defined string).
description: Option<String>Human-readable description of the error. Optional per RFC 8620 §5.3.
properties: Option<Vec<String>>Property names that caused the error (for invalidProperties).
existing_id: Option<Id>The existing object id (for alreadyExists).
not_found: Option<Vec<Id>>Missing blob ids (for blobNotFound).
max_recipients: Option<u64>Maximum recipients allowed (for tooManyRecipients).
invalid_recipients: Option<Vec<String>>Invalid recipient addresses (for invalidRecipients).
max_size: Option<u64>Maximum message size in octets (for tooLarge).
extra: Map<String, Value>Catch-all for extension SetError fields not in the RFC 8620 base
set. Captured via #[serde(flatten)] so they round-trip losslessly.
Extension crates provide typed accessors (e.g.
jmap-chat-client’s helper for reading serverRetryAfter).
Uses serde_json::Map (which, under the workspace’s default
serde_json features — preserve_order is NOT enabled — is
backed by BTreeMap and therefore deterministically serializes
in lexicographic key order, NOT in insertion order) rather than
HashMap to match the workspace extras-preservation policy (see
workspace AGENTS.md) and to give callers deterministic serialized
output.
Implementations§
Source§impl SetError
impl SetError
Sourcepub fn new(error_type: impl Into<String>) -> SetError
pub fn new(error_type: impl Into<String>) -> SetError
Construct a SetError with the given type string and all optional
fields None / empty. Use this when deserializing tests or when
constructing a wire-shaped error from a typed source. Server crates
that want a typed enum for construction should use
jmap_server::backend::SetError (declared in the jmap-server
crate, not linkable from here since jmap-types does not depend on
jmap-server) — this type is deliberately String-typed for
client-side parsing flexibility.
§Caller contract — input is not validated
error_type is stored verbatim. The constructor does not check
that the string is non-empty, that it matches an RFC 8620 §5.3
known type, or that the optional fields populated elsewhere on
the struct are consistent with the chosen type. SetError::new("")
succeeds and produces a wire-noncompliant {"type":""} shape.
Callers who want compile-time guarantees should construct
jmap_server::backend::SetError (the typed enum) and convert,
rather than calling this constructor with a raw string. Callers
who do want raw-string construction (e.g. proxies forwarding an
upstream’s error) MUST validate the input themselves before
passing it here. This matches the workspace pattern for the
other permissive constructors in this crate
(crate::Id::from, crate::UTCDate::from — see the
jmap-types README “Gotchas” section).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for SetError
impl<'de> Deserialize<'de> for SetError
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<SetError, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<SetError, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for SetError
impl Serialize for SetError
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for SetError
Auto Trait Implementations§
impl Freeze for SetError
impl RefUnwindSafe for SetError
impl Send for SetError
impl Sync for SetError
impl Unpin for SetError
impl UnsafeUnpin for SetError
impl UnwindSafe for SetError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.