pub struct TokenScope { /* private fields */ }Expand description
Actions a token can authorize.
Implementations§
Source§impl TokenScope
impl TokenScope
Sourcepub const NONE: TokenScope
pub const NONE: TokenScope
No permissions.
Sourcepub const PUBLISH: TokenScope
pub const PUBLISH: TokenScope
Publish events to a channel.
Sourcepub const SUBSCRIBE: TokenScope
pub const SUBSCRIBE: TokenScope
Subscribe to events from a channel.
Sourcepub const ADMIN: TokenScope
pub const ADMIN: TokenScope
Administrative access (create/delete channels, manage tokens).
Sourcepub const DELEGATE: TokenScope
pub const DELEGATE: TokenScope
Can delegate this token to other entities.
Sourcepub const WILDCARD: TokenScope
pub const WILDCARD: TokenScope
Wildcard over channels: authorizes the token’s actions on every
channel, regardless of the token’s channel_hash field. Must be
set explicitly by the issuer — the previous “channel_hash == 0
means wildcard” overload is no longer honored, so a legitimate
channel whose xxh3-truncated ChannelHash happens to hash to 0
cannot accidentally be authorized as a universal grant.
Sourcepub const ALL: TokenScope
pub const ALL: TokenScope
Full access (all actions on a single channel). Does NOT include
Self::WILDCARD — callers that want cross-channel access
must opt in explicitly.
Sourcepub const fn from_bits(bits: u32) -> TokenScope
pub const fn from_bits(bits: u32) -> TokenScope
Create a scope from raw bits.
Sourcepub const fn contains(self, other: TokenScope) -> bool
pub const fn contains(self, other: TokenScope) -> bool
Check if this scope includes another.
A scope never “contains” NONE: the bit-mask identity
(self.bits & 0) == 0 would otherwise return true for every
token, so a caller that builds action: TokenScope from
external input — e.g. a wire u32 masked into a smaller
subset — that happens to mask to NONE would receive a
blanket true against any token. Short-circuit NONE so the
caller’s “do they have permission X” question rejects the
no-op action.
Sourcepub const fn intersect(self, other: TokenScope) -> TokenScope
pub const fn intersect(self, other: TokenScope) -> TokenScope
Restrict this scope to only include permissions in other.
Sourcepub const fn union(self, other: TokenScope) -> TokenScope
pub const fn union(self, other: TokenScope) -> TokenScope
Combine with another scope.
Sourcepub fn with_channel(self, channel_hash: u32) -> ScopedToken
pub fn with_channel(self, channel_hash: u32) -> ScopedToken
Optional channel hash filter. If set, token only applies to
channels matching this canonical ChannelHash.
Trait Implementations§
Source§impl Clone for TokenScope
impl Clone for TokenScope
Source§fn clone(&self) -> TokenScope
fn clone(&self) -> TokenScope
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TokenScope
impl Debug for TokenScope
Source§impl PartialEq for TokenScope
impl PartialEq for TokenScope
Source§fn eq(&self, other: &TokenScope) -> bool
fn eq(&self, other: &TokenScope) -> bool
self and other values to be equal, and is used by ==.