pub struct Agency {
pub max_children: Option<usize>,
pub allowed_roles: Vec<AgentRole>,
pub capability_ceiling: AgentCapabilities,
pub children: Vec<Pid>,
}Expand description
Agency: the ability to spawn child agents.
Hierarchical: root has unlimited agency, supervisors can spawn service/worker agents, services can spawn workers only, and workers have no agency.
Fields§
§max_children: Option<usize>Maximum number of child agents this agent can spawn. None = unlimited.
allowed_roles: Vec<AgentRole>Which roles this agent is allowed to spawn.
capability_ceiling: AgentCapabilitiesCapability ceiling: spawned agents cannot exceed these capabilities.
children: Vec<Pid>Currently spawned child PIDs.
Implementations§
Source§impl Agency
impl Agency
Sourcepub fn supervisor(max_children: usize) -> Self
pub fn supervisor(max_children: usize) -> Self
Supervisor: can spawn services and workers.
Sourcepub fn can_spawn(&self, role: &AgentRole) -> bool
pub fn can_spawn(&self, role: &AgentRole) -> bool
Check if this agency allows spawning a child with the given role.
Sourcepub fn remove_child(&mut self, pid: Pid)
pub fn remove_child(&mut self, pid: Pid)
Remove a terminated child.
Sourcepub fn remaining_capacity(&self) -> Option<usize>
pub fn remaining_capacity(&self) -> Option<usize>
How many children remain before hitting the limit.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Agency
impl<'de> Deserialize<'de> for Agency
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Agency
impl RefUnwindSafe for Agency
impl Send for Agency
impl Sync for Agency
impl Unpin for Agency
impl UnsafeUnpin for Agency
impl UnwindSafe for Agency
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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