pub enum Argument<T: Sealed> {
Value(T),
Ref(ResultReference),
}Expand description
A JMAP method argument that can be either a direct value or a ResultReference.
In JMAP JSON, a ResultReference is indicated by a “#” prefix on the key:
"ids": [...] → Argument::Value([…])
"#ids": {...} → Argument::Ref(ResultReference { … })
The resolver in kith-jmap evaluates Ref variants before method dispatch.
§Deserialization note
Uses #[serde(untagged)] which tries to deserialize as T first.
If T and ResultReference share field names, T is preferred.
Callers must handle the # key prefix before deserializing.
§Invariant
T must not deserialize from a JSON object with keys resultOf, name,
and path. If T accepts arbitrary JSON objects, #[serde(untagged)]
will match T before trying Ref, silently swallowing any
ResultReference payload. The sealed set is chosen specifically to exclude
struct types for this reason. Never implement Sealed for a type that
deserializes from a JSON object.
§Type safety
T is constrained to sealed::Sealed types. serde_json::Value does NOT
implement Sealed — Argument<Value> therefore fails to compile. This
prevents a silent bug: Value accepts any JSON, so with T = Value the
Ref variant can never be reached via serde; every ResultReference JSON
would deserialize as Argument::Value(json_object) and the reference would
be silently ignored.
use jmap_types::resultref::Argument;
// serde_json::Value does not implement Sealed — this must not compile.
let _: Argument<serde_json::Value> = Argument::Value(serde_json::Value::Null);Variants§
Value(T)
A direct, inlined argument value supplied by the caller.
Ref(ResultReference)
A result-reference back to a previous method response in the same request (RFC 8620 §3.7), resolved by the dispatcher before invoking the method handler.