#[non_exhaustive]pub struct ChatLimits {
pub max_roles_per_space: u32,
pub max_space_members: u32,
pub max_channels_per_space: u32,
pub max_categories_per_space: u32,
pub max_group_chat_members: u32,
pub supported_body_types: &'static [&'static str],
pub server_reserved_body_types: &'static [&'static str],
pub encrypted_body_types: &'static [&'static str],
pub supports_threads: bool,
pub max_body_bytes: u64,
pub max_attachment_bytes: u64,
pub max_attachments_per_message: u64,
}Expand description
Implementation-defined per-Space content limits enforced by
Space/set handlers.
Per draft-atwood-jmap-chat-00 §Space/set (spec commit 80d5e11,
2026-05-11), each add* op on a Space MUST return an overQuota
SetError (RFC 8620 §5.3) when the resulting count would exceed a
server-defined limit. The spec does not name or normatively define
the cap values; they are implementation-defined and may vary per
account or per tenant.
Backends override ChatBackend::limits to supply their own values.
The default impl returns conservative reference-impl-grade values
suitable for tests and single-tenant dev servers; production
deployments are expected to override.
Client visibility of these caps (when desired) is via JMAP Quotas
(urn:ietf:params:jmap:quotas, RFC 9425), not via this struct.
The urn:ietf:params:jmap:chat session capability does NOT advertise
the count caps (the previous cap-advertising fields maxRolesPerSpace,
maxSpaceMembers, maxChannelsPerSpace, maxCategoriesPerSpace
were removed from the draft in spec commit 80d5e11).
See the workspace AGENTS.md “Backend caps and limits” section for
the cross-extension pattern this struct establishes for JMAP Chat.
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.max_roles_per_space: u32Maximum number of roles per Space. Enforced against the
resulting count after applying every addRoles entry in a
Space/set update patch.
max_space_members: u32Maximum number of members per Space. Enforced against the
resulting count after applying every addMembers entry in a
Space/set update patch.
max_channels_per_space: u32Maximum number of channels per Space. Enforced against the
resulting count after applying every addChannels entry in a
Space/set update patch. The current channel count is the sum
of space.uncategorizedChannelIds.len() and every
space.categories[].channelIds.len().
max_categories_per_space: u32Maximum number of categories per Space. Enforced against the
resulting count after applying every addCategories entry in
a Space/set update patch.
max_group_chat_members: u32Maximum number of members per group Chat. Enforced against the
resulting count after applying every addMembers entry in a
Chat/set update patch.
supported_body_types: &'static [&'static str]bodyType values the account advertises as supportedBodyTypes
and Message/set accepts (draft-atwood-jmap-chat-00
§Account-Level Capability Object). Defaults to
crate::message::SUPPORTED_BODY_TYPES. The list “MUST include
"text/plain" unless the server accepts only end-to-end encrypted
body types”; Message/set rejects a bodyType not listed here,
including the implied "text/plain" of an omitted bodyType.
server_reserved_body_types: &'static [&'static str]Listed types that a companion specification reserves for
server-created Messages (e.g. "application/mimi-fanout",
draft-atwood-jmap-chat-mimi-00). Message/set create rejects
them with an invalidProperties SetError naming bodyType;
update does not. Defaults to empty.
encrypted_body_types: &'static [&'static str]bodyType values that indicate an end-to-end encrypted body.
Defaults to crate::message::ENCRYPTED_BODY_TYPES. For these
types Message/set create and update reject a non-empty
mentions, broadcastMentions, attachments, actions,
replyTo, threadRootId, topicId or subject
(draft-atwood-jmap-chat-00 §Fields Inside the Ciphertext). A MIMI
deployment adds "application/mimi-fanout", which “is an
encrypted body type for the purposes of” that draft
(draft-atwood-jmap-chat-mimi-00 §MLS Messages).
supports_threads: boolThe account’s supportsThreads capability value
(draft-atwood-jmap-chat-00 §Thread Model). When true,
Message/get computes replyCount and unreadReplyCount, and
Message/query accepts the threadRootId filter, which the
backend’s query_objects must then implement. Defaults to false.
max_body_bytes: u64The account’s maxBodyBytes capability value
(draft-atwood-jmap-chat-00 §Account-Level Capability Object):
“Maximum UTF-8 byte length of a Message body.” Message/set
create rejects a longer body with a tooLarge SetError.
Defaults to 100,000.
max_attachment_bytes: u64The account’s maxAttachmentBytes capability value: “Maximum size
in bytes of a single attachment blob.” Message/set create
rejects an Attachment whose size exceeds it with a tooLarge
SetError, before consulting ChatBackend::attachment_blob.
Defaults to 50,000,000.
max_attachments_per_message: u64The account’s maxAttachmentsPerMessage capability value:
“Maximum number of attachments per message.” Message/set create
rejects more with a tooLarge SetError. Defaults to 16.
Implementations§
Source§impl ChatLimits
impl ChatLimits
Sourcepub const fn new(
max_roles_per_space: u32,
max_space_members: u32,
max_channels_per_space: u32,
max_categories_per_space: u32,
) -> Self
pub const fn new( max_roles_per_space: u32, max_space_members: u32, max_channels_per_space: u32, max_categories_per_space: u32, ) -> Self
Construct a ChatLimits with the four Space cap fields
specified in declaration order: roles, members, channels,
categories. Self::max_group_chat_members defaults to 1000;
override it with Self::with_max_group_chat_members.
The struct is #[non_exhaustive] so external callers (tests
using MemoryBackend::set_limits_for_test, production backends
overriding ChatBackend::limits) need a constructor to build
one. Future cap-field additions to ChatLimits are an
additive non-breaking change because the constructor stays
stable; callers wanting to override the new field combine
ChatLimits::new(..) with Self::with_max_roles_per_space
/ Self::with_max_space_members /
Self::with_max_channels_per_space /
Self::with_max_categories_per_space and a future analogous
setter.
Sourcepub const fn with_max_roles_per_space(self, max: u32) -> Self
pub const fn with_max_roles_per_space(self, max: u32) -> Self
Builder-style setter for Self::max_roles_per_space.
Sourcepub const fn with_max_space_members(self, max: u32) -> Self
pub const fn with_max_space_members(self, max: u32) -> Self
Builder-style setter for Self::max_space_members.
Sourcepub const fn with_max_channels_per_space(self, max: u32) -> Self
pub const fn with_max_channels_per_space(self, max: u32) -> Self
Builder-style setter for Self::max_channels_per_space.
Sourcepub const fn with_max_categories_per_space(self, max: u32) -> Self
pub const fn with_max_categories_per_space(self, max: u32) -> Self
Builder-style setter for Self::max_categories_per_space.
Sourcepub const fn with_max_group_chat_members(self, max: u32) -> Self
pub const fn with_max_group_chat_members(self, max: u32) -> Self
Builder-style setter for Self::max_group_chat_members.
Sourcepub const fn with_supported_body_types(
self,
types: &'static [&'static str],
) -> Self
pub const fn with_supported_body_types( self, types: &'static [&'static str], ) -> Self
Builder-style setter for Self::supported_body_types.
Sourcepub const fn with_server_reserved_body_types(
self,
types: &'static [&'static str],
) -> Self
pub const fn with_server_reserved_body_types( self, types: &'static [&'static str], ) -> Self
Builder-style setter for Self::server_reserved_body_types.
Sourcepub const fn with_encrypted_body_types(
self,
types: &'static [&'static str],
) -> Self
pub const fn with_encrypted_body_types( self, types: &'static [&'static str], ) -> Self
Builder-style setter for Self::encrypted_body_types.
Sourcepub const fn with_supports_threads(self, supports: bool) -> Self
pub const fn with_supports_threads(self, supports: bool) -> Self
Builder-style setter for Self::supports_threads.
Sourcepub const fn with_max_body_bytes(self, max: u64) -> Self
pub const fn with_max_body_bytes(self, max: u64) -> Self
Builder-style setter for Self::max_body_bytes.
Sourcepub const fn with_max_attachment_bytes(self, max: u64) -> Self
pub const fn with_max_attachment_bytes(self, max: u64) -> Self
Builder-style setter for Self::max_attachment_bytes.
Sourcepub const fn with_max_attachments_per_message(self, max: u64) -> Self
pub const fn with_max_attachments_per_message(self, max: u64) -> Self
Builder-style setter for Self::max_attachments_per_message.
Trait Implementations§
Source§impl Clone for ChatLimits
impl Clone for ChatLimits
impl Copy for ChatLimits
Source§impl Debug for ChatLimits
impl Debug for ChatLimits
Source§impl Default for ChatLimits
impl Default for ChatLimits
impl Eq for ChatLimits
Source§impl PartialEq for ChatLimits
impl PartialEq for ChatLimits
impl StructuralPartialEq for ChatLimits
Auto Trait Implementations§
impl Freeze for ChatLimits
impl RefUnwindSafe for ChatLimits
impl Send for ChatLimits
impl Sync for ChatLimits
impl Unpin for ChatLimits
impl UnsafeUnpin for ChatLimits
impl UnwindSafe for ChatLimits
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,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.