Skip to main content

ChannelConfig

Struct ChannelConfig 

Source
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

Source

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());
Source

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);
Source

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);
Source

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);
Source

pub const fn priority(&self) -> u8

Returns the scheduling priority.

Higher values indicate higher priority for scheduling.

Source

pub const fn can_spawn(&self) -> bool

Returns whether this channel can spawn children.

Source

pub const fn max_privilege(&self) -> MaxPrivilege

Returns the maximum privilege level.

Source

pub const fn with_priority(self, priority: u8) -> Self

Returns a new config with the specified priority.

Source

pub const fn with_spawn(self, can_spawn: bool) -> Self

Returns a new config with spawn permission set.

Source

pub const fn with_max_privilege(self, max_privilege: MaxPrivilege) -> Self

Returns a new config with the specified max privilege.

Source

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

Source§

fn clone(&self) -> ChannelConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ChannelConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ChannelConfig

Source§

fn default() -> Self

Default configuration with normal priority, spawn enabled, and standard privilege.

Source§

impl<'de> Deserialize<'de> for ChannelConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for ChannelConfig

Source§

fn eq(&self, other: &ChannelConfig) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for ChannelConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Copy for ChannelConfig

Source§

impl Eq for ChannelConfig

Source§

impl StructuralPartialEq for ChannelConfig

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,