pub enum SignalScope {
Global,
Channel(ChannelId),
WithChildren(ChannelId),
}Expand description
The scope affected by a signal or permission check.
Defines the boundary of effect for control operations.
§Scope Hierarchy
Global
└── WithChildren (channel + descendants)
└── Channel (specific only)§Permission Requirements
| Scope | Standard Privilege | Elevated Privilege |
|---|---|---|
Global | Denied | Allowed |
WithChildren (own) | Allowed | Allowed |
WithChildren (other) | Denied | Allowed |
Channel (own) | Allowed | Allowed |
Channel (other) | Denied | Allowed |
§Example
use orcs_types::{SignalScope, ChannelId};
let global = SignalScope::Global;
let channel = SignalScope::Channel(ChannelId::new());
let with_children = SignalScope::WithChildren(ChannelId::new());
assert!(global.is_global());
assert!(!channel.is_global());
assert!(with_children.includes_descendants());Variants§
Global
Affects all channels and components.
Requires elevated privilege.
Channel(ChannelId)
Affects a specific channel only.
WithChildren(ChannelId)
Affects a channel and all its descendants.
Use this when you want to signal a subtree of channels. Descendant checking requires World access at runtime.
Implementations§
Source§impl SignalScope
impl SignalScope
Sourcepub fn is_global(&self) -> bool
pub fn is_global(&self) -> bool
Returns true if this is a Global scope.
§Example
use orcs_types::SignalScope;
assert!(SignalScope::Global.is_global());Sourcepub fn includes_descendants(&self) -> bool
pub fn includes_descendants(&self) -> bool
Returns true if this scope includes descendants.
Both Global and WithChildren include descendants.
§Example
use orcs_types::{SignalScope, ChannelId};
assert!(SignalScope::Global.includes_descendants());
assert!(SignalScope::WithChildren(ChannelId::new()).includes_descendants());
assert!(!SignalScope::Channel(ChannelId::new()).includes_descendants());Sourcepub fn affects(&self, channel: ChannelId) -> bool
pub fn affects(&self, channel: ChannelId) -> bool
Returns true if this scope affects the given channel (without descendant check).
For WithChildren, this only checks the root channel.
Use affects_with_descendants() for full descendant checking.
§Example
use orcs_types::{SignalScope, ChannelId};
let ch1 = ChannelId::new();
let ch2 = ChannelId::new();
assert!(SignalScope::Global.affects(ch1));
assert!(SignalScope::Channel(ch1).affects(ch1));
assert!(!SignalScope::Channel(ch1).affects(ch2));Sourcepub fn affects_with_descendants<F>(
&self,
channel: ChannelId,
is_descendant: F,
) -> bool
pub fn affects_with_descendants<F>( &self, channel: ChannelId, is_descendant: F, ) -> bool
Checks if this scope affects the given channel, with descendant support.
The is_descendant closure is called for WithChildren scope to check
if the channel is a descendant of the scope’s root.
§Arguments
channel- The channel to checkis_descendant- Closure that returnstrueifchannelis a descendant of the scope root
§Example
use orcs_types::{SignalScope, ChannelId};
let root = ChannelId::new();
let child = ChannelId::new();
let other = ChannelId::new();
let scope = SignalScope::WithChildren(root);
// Simulate: child is descendant of root, other is not
assert!(scope.affects_with_descendants(root, |_| false)); // root itself
assert!(scope.affects_with_descendants(child, |ch| ch == child)); // child
assert!(!scope.affects_with_descendants(other, |_| false)); // unrelatedTrait Implementations§
Source§impl Clone for SignalScope
impl Clone for SignalScope
Source§fn clone(&self) -> SignalScope
fn clone(&self) -> SignalScope
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more