pub struct Capability(/* private fields */);Expand description
A capability document: resource pattern → set of allowed operation strings.
Operation strings are stored (not the enum) so the BTreeSet sorts
lexicographically by wire value, matching Ably’s canonicalization.
Implementations§
Source§impl Capability
impl Capability
Sourcepub fn allow(
self,
resource: impl Into<String>,
ops: impl IntoIterator<Item = Operation>,
) -> Self
pub fn allow( self, resource: impl Into<String>, ops: impl IntoIterator<Item = Operation>, ) -> Self
Grant ops on resource (a channel-name pattern, e.g. "room",
"dms:*", "*"). Repeated resources merge.
Sourcepub fn to_capability_string(&self) -> String
pub fn to_capability_string(&self) -> String
The canonical capability string for a TokenRequest or an
x-ably-capability JWT claim: sorted resource keys, sorted operations,
no whitespace.
Sourcepub fn for_room(
self,
room: &str,
ops: impl IntoIterator<Item = Operation>,
) -> Self
pub fn for_room( self, room: &str, ops: impl IntoIterator<Item = Operation>, ) -> Self
Grant ops on a chat room, scoped by room name.
Uses the bare room name, which Ably’s product model expands to authorize
both the /chat/v4 REST API and the room::$chat channel. Do not pass
"{room}::$chat" here — that authorizes only the realtime channel and would
40160 on REST. The explicit product qualifier [chat]{room} is available
via Capability::allow.
NOTE (pre-1.0): the exact resource form is confirmed only to moderate-high
confidence; verify against a live app before stabilization (see
docs/research/2026-07-24-ably-chat-auth-permissions.md §A2.2).
Trait Implementations§
Source§impl Clone for Capability
impl Clone for Capability
Source§fn clone(&self) -> Capability
fn clone(&self) -> Capability
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more