Skip to main content

ChatLimits

Struct ChatLimits 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§max_roles_per_space: u32

Maximum number of roles per Space. Enforced against the resulting count after applying every addRoles entry in a Space/set update patch.

§max_space_members: u32

Maximum 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: u32

Maximum 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: u32

Maximum 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: u32

Maximum 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: bool

The 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: u64

The 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: u64

The 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: u64

The 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

Source

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.

Source

pub const fn with_max_roles_per_space(self, max: u32) -> Self

Builder-style setter for Self::max_roles_per_space.

Source

pub const fn with_max_space_members(self, max: u32) -> Self

Builder-style setter for Self::max_space_members.

Source

pub const fn with_max_channels_per_space(self, max: u32) -> Self

Builder-style setter for Self::max_channels_per_space.

Source

pub const fn with_max_categories_per_space(self, max: u32) -> Self

Builder-style setter for Self::max_categories_per_space.

Source

pub const fn with_max_group_chat_members(self, max: u32) -> Self

Builder-style setter for Self::max_group_chat_members.

Source

pub const fn with_supported_body_types( self, types: &'static [&'static str], ) -> Self

Builder-style setter for Self::supported_body_types.

Source

pub const fn with_server_reserved_body_types( self, types: &'static [&'static str], ) -> Self

Builder-style setter for Self::server_reserved_body_types.

Source

pub const fn with_encrypted_body_types( self, types: &'static [&'static str], ) -> Self

Builder-style setter for Self::encrypted_body_types.

Source

pub const fn with_supports_threads(self, supports: bool) -> Self

Builder-style setter for Self::supports_threads.

Source

pub const fn with_max_body_bytes(self, max: u64) -> Self

Builder-style setter for Self::max_body_bytes.

Source

pub const fn with_max_attachment_bytes(self, max: u64) -> Self

Builder-style setter for Self::max_attachment_bytes.

Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ChatLimits

Source§

impl Debug for ChatLimits

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ChatLimits

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for ChatLimits

Source§

impl PartialEq for ChatLimits

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ChatLimits

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more