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 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SignalScope
impl Debug for SignalScope
Source§impl<'de> Deserialize<'de> for SignalScope
impl<'de> Deserialize<'de> for SignalScope
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<SignalScope, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<SignalScope, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Display for SignalScope
impl Display for SignalScope
impl Eq for SignalScope
Source§impl PartialEq for SignalScope
impl PartialEq for SignalScope
Source§impl Serialize for SignalScope
impl Serialize for SignalScope
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for SignalScope
Auto Trait Implementations§
impl Freeze for SignalScope
impl RefUnwindSafe for SignalScope
impl Send for SignalScope
impl Sync for SignalScope
impl Unpin for SignalScope
impl UnsafeUnpin for SignalScope
impl UnwindSafe for SignalScope
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> MaybeSend for Twhere
T: Send,
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> Serialize for T
impl<T> Serialize for T
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>
fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.