pub struct ChannelConfig { /* private fields */ }Expand description
Configuration for a Channel.
Defines behavioral attributes without requiring separate types. This approach allows flexible channel behavior while maintaining a simple, unified Channel struct.
§Privilege Inheritance
When spawning child channels, max_privilege is inherited:
- Child cannot exceed parent’s
max_privilege - Use
inherit_from()to apply inheritance
§Example
use orcs_runtime::{ChannelConfig, MaxPrivilege};
let config = ChannelConfig::interactive();
assert!(config.can_spawn());
assert_eq!(config.priority(), 255);
assert_eq!(config.max_privilege(), MaxPrivilege::Elevated);
let bg = ChannelConfig::background();
assert!(!bg.can_spawn());
assert_eq!(bg.max_privilege(), MaxPrivilege::Standard);Implementations§
Source§impl ChannelConfig
impl ChannelConfig
Sourcepub const fn new(priority: u8, can_spawn: bool) -> Self
pub const fn new(priority: u8, can_spawn: bool) -> Self
Creates a new configuration with specified attributes.
Uses MaxPrivilege::Standard by default. For elevated channels,
use with_max_privilege().
§Arguments
priority- Scheduling priority (0-255)can_spawn- Whether child channels can be spawned
§Example
use orcs_runtime::ChannelConfig;
let config = ChannelConfig::new(100, true);
assert_eq!(config.priority(), 100);
assert!(config.can_spawn());Sourcepub const fn interactive() -> Self
pub const fn interactive() -> Self
Configuration for interactive channels.
Interactive channels:
- Have highest priority (255)
- Can spawn child channels
- Have elevated privilege capability
- Used for Human direct interaction (IO)
§Example
use orcs_runtime::{ChannelConfig, MaxPrivilege};
let config = ChannelConfig::interactive();
assert_eq!(config.priority(), 255);
assert!(config.can_spawn());
assert_eq!(config.max_privilege(), MaxPrivilege::Elevated);Sourcepub const fn background() -> Self
pub const fn background() -> Self
Configuration for background channels.
Background channels:
- Have lowest priority (10)
- Cannot spawn child channels
- Have standard privilege only
- Used for parallel/async tasks
§Example
use orcs_runtime::{ChannelConfig, MaxPrivilege};
let config = ChannelConfig::background();
assert_eq!(config.priority(), 10);
assert!(!config.can_spawn());
assert_eq!(config.max_privilege(), MaxPrivilege::Standard);Sourcepub const fn tool() -> Self
pub const fn tool() -> Self
Configuration for tool execution channels.
Tool channels:
- Have medium-high priority (100)
- Can spawn child channels (for sub-tools)
- Have elevated privilege capability
- Spawned for specific operations
§Example
use orcs_runtime::{ChannelConfig, MaxPrivilege};
let config = ChannelConfig::tool();
assert_eq!(config.priority(), 100);
assert!(config.can_spawn());
assert_eq!(config.max_privilege(), MaxPrivilege::Elevated);Sourcepub const fn priority(&self) -> u8
pub const fn priority(&self) -> u8
Returns the scheduling priority.
Higher values indicate higher priority for scheduling.
Sourcepub const fn max_privilege(&self) -> MaxPrivilege
pub const fn max_privilege(&self) -> MaxPrivilege
Returns the maximum privilege level.
Sourcepub const fn with_priority(self, priority: u8) -> Self
pub const fn with_priority(self, priority: u8) -> Self
Returns a new config with the specified priority.
Sourcepub const fn with_spawn(self, can_spawn: bool) -> Self
pub const fn with_spawn(self, can_spawn: bool) -> Self
Returns a new config with spawn permission set.
Sourcepub const fn with_max_privilege(self, max_privilege: MaxPrivilege) -> Self
pub const fn with_max_privilege(self, max_privilege: MaxPrivilege) -> Self
Returns a new config with the specified max privilege.
Sourcepub fn inherit_from(self, parent: &ChannelConfig) -> Self
pub fn inherit_from(self, parent: &ChannelConfig) -> Self
Returns a config that inherits constraints from a parent.
The child’s max_privilege is capped by the parent’s level.
This ensures privilege reduction propagates down the channel tree.
§Example
use orcs_runtime::{ChannelConfig, MaxPrivilege};
let parent = ChannelConfig::background(); // Standard privilege
let child_request = ChannelConfig::tool(); // Elevated privilege
let actual = child_request.inherit_from(&parent);
// Child is capped to parent's Standard level
assert_eq!(actual.max_privilege(), MaxPrivilege::Standard);Trait Implementations§
Source§impl Clone for ChannelConfig
impl Clone for ChannelConfig
Source§fn clone(&self) -> ChannelConfig
fn clone(&self) -> ChannelConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ChannelConfig
impl Debug for ChannelConfig
Source§impl Default for ChannelConfig
impl Default for ChannelConfig
Source§impl<'de> Deserialize<'de> for ChannelConfig
impl<'de> Deserialize<'de> for ChannelConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for ChannelConfig
impl PartialEq for ChannelConfig
Source§impl Serialize for ChannelConfig
impl Serialize for ChannelConfig
impl Copy for ChannelConfig
impl Eq for ChannelConfig
impl StructuralPartialEq for ChannelConfig
Auto Trait Implementations§
impl Freeze for ChannelConfig
impl RefUnwindSafe for ChannelConfig
impl Send for ChannelConfig
impl Sync for ChannelConfig
impl Unpin for ChannelConfig
impl UnsafeUnpin for ChannelConfig
impl UnwindSafe for ChannelConfig
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,
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.