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) -> ChannelConfig
pub const fn new(priority: u8, can_spawn: bool) -> ChannelConfig
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() -> ChannelConfig
pub const fn interactive() -> ChannelConfig
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() -> ChannelConfig
pub const fn background() -> ChannelConfig
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() -> ChannelConfig
pub const fn tool() -> ChannelConfig
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) -> ChannelConfig
pub const fn with_priority(self, priority: u8) -> ChannelConfig
Returns a new config with the specified priority.
Sourcepub const fn with_spawn(self, can_spawn: bool) -> ChannelConfig
pub const fn with_spawn(self, can_spawn: bool) -> ChannelConfig
Returns a new config with spawn permission set.
Sourcepub const fn with_max_privilege(
self,
max_privilege: MaxPrivilege,
) -> ChannelConfig
pub const fn with_max_privilege( self, max_privilege: MaxPrivilege, ) -> ChannelConfig
Returns a new config with the specified max privilege.
Sourcepub fn inherit_from(self, parent: &ChannelConfig) -> ChannelConfig
pub fn inherit_from(self, parent: &ChannelConfig) -> ChannelConfig
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 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ChannelConfig
Source§impl Debug for ChannelConfig
impl Debug for ChannelConfig
Source§impl Default for ChannelConfig
impl Default for ChannelConfig
Source§fn default() -> ChannelConfig
fn default() -> ChannelConfig
Default configuration with normal priority, spawn enabled, and standard privilege.
Source§impl<'de> Deserialize<'de> for ChannelConfig
impl<'de> Deserialize<'de> for ChannelConfig
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ChannelConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ChannelConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Eq for ChannelConfig
Source§impl PartialEq for ChannelConfig
impl PartialEq for ChannelConfig
Source§impl Serialize for ChannelConfig
impl Serialize for ChannelConfig
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 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,
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 more