#[non_exhaustive]pub struct PushSubscriptionCreateInput<'a> {
pub client_id: Option<&'a str>,
pub device_client_id: &'a str,
pub url: &'a str,
pub expires: Option<&'a UTCDate>,
pub types: Option<&'a [&'a str]>,
pub chat_push: Option<&'a [(&'a Id, ChatPushConfig)]>,
}Expand description
Input parameters for PushSubscription/set create (RFC 8620 §7.2).
Creates a PushSubscription with the optional chatPush extension
(draft-atwood-jmap-chat-push-00 §3.1).
device_client_id and url have no safe defaults and must always be supplied.
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.client_id: Option<&'a str>Caller-supplied creation key. When None — or Some("") — a ULID
is generated automatically. An empty Some("") is treated the same
as None, not as a rejection; callers must not assume the wire
echoes a caller-supplied empty string.
device_client_id: &'a strStable client device identifier, used by the server to deduplicate subscriptions.
Precondition: must be non-empty.
Self::push_subscription_create
rejects an empty value client-side with
ClientError::InvalidArgument.
url: &'a strPush endpoint URL registered with the platform push service.
Precondition: must be non-empty.
Self::push_subscription_create
rejects an empty value client-side with
ClientError::InvalidArgument.
Malformed-but-non-empty URLs forward to the server, which rejects
them with a setError on the creation entry. No client-side URL
syntax check is performed.
expires: Option<&'a UTCDate>Subscription expiry time. None lets the server choose.
types: Option<&'a [&'a str]>Data type names to include in StateChange notifications.
None means the server delivers all changed types.
chat_push: Option<&'a [(&'a Id, ChatPushConfig)]>Per-account ChatPushConfig entries for inline push. Each entry is
(accountId, config). Pass None to omit the chatPush property.
§Why a slice-of-pairs, not a HashMap?
The wire form is a JSON object keyed by accountId (a HashMap
shape). The slice-of-pairs input form is deliberate:
- Most callers know their per-account configs at construction
time and can supply them as an array literal; forcing
&HashMap<Id, _>would require a.collect()or aHashMap::from([...])site at every call. Iddoes not deriveOrd, so a deterministic-iteration alternative would have to beBTreeMap<Id, _>, which requires a workspace-wide Ord propagation pass to add.HashMap<Id, _>would give non-deterministic JSON output (test fixtures and snapshot tests would become order-flaky).- The runtime duplicate-accountId check
(
ClientError::InvalidArgument) is small, shared between create and update viabuild_chat_push_map, and has unit-test coverage.
The trade-off is one runtime check per call site against an
ergonomic gain for the common case. If a future workspace pass
adds Ord to Id, a follow-up bead can re-evaluate.
Implementations§
Source§impl<'a> PushSubscriptionCreateInput<'a>
impl<'a> PushSubscriptionCreateInput<'a>
Sourcepub fn new(device_client_id: &'a str, url: &'a str) -> Self
pub fn new(device_client_id: &'a str, url: &'a str) -> Self
Create a PushSubscriptionCreateInput with required fields; optional fields default to None.
Sourcepub fn with_client_id(self, id: &'a str) -> Self
pub fn with_client_id(self, id: &'a str) -> Self
Set the caller-supplied creation key (overrides the auto-generated ULID).
Sourcepub fn with_types(self, types: &'a [&'a str]) -> Self
pub fn with_types(self, types: &'a [&'a str]) -> Self
Restrict StateChange notifications to these data type names.
Sourcepub fn with_chat_push(self, chat_push: &'a [(&'a Id, ChatPushConfig)]) -> Self
pub fn with_chat_push(self, chat_push: &'a [(&'a Id, ChatPushConfig)]) -> Self
Attach per-account ChatPushConfig entries for inline push.
Trait Implementations§
Source§impl<'a> Clone for PushSubscriptionCreateInput<'a>
impl<'a> Clone for PushSubscriptionCreateInput<'a>
Source§fn clone(&self) -> PushSubscriptionCreateInput<'a>
fn clone(&self) -> PushSubscriptionCreateInput<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more