Struct AgentRuntime

Source
pub struct AgentRuntime(/* private fields */);
Expand description

Represents a ready state of the Acton system.

This struct encapsulates the internal state of the Acton system when it’s ready for use. It provides methods for creating and managing actors within the system.

Implementations§

Source§

impl AgentRuntime

Source

pub async fn new_agent_with_name<State>( &mut self, name: String, ) -> ManagedAgent<Idle, State>
where State: Default + Send + Debug + 'static,

Creates a new actor with the provided id root name.

§Type Parameters
  • State - The state type of the actor, which must implement Default, Send, Debug, and have a static lifetime.
§Returns

A ManagedActor in the Idle state with the specified State.

Source

pub async fn new_agent<State>(&mut self) -> ManagedAgent<Idle, State>
where State: Default + Send + Debug + 'static,

Creates a new actor with default configuration.

§Type Parameters
  • State - The state type of the actor, which must implement Default, Send, Debug, and have a static lifetime.
§Returns

A ManagedActor in the Idle state with the specified State.

Source

pub fn agent_count(&self) -> usize

Retrieves the number of actors currently running in the system.

Source

pub async fn create_actor_with_config<State>( &mut self, config: AgentConfig, ) -> ManagedAgent<Idle, State>
where State: Default + Send + Debug + 'static,

Creates a new actor with a specified configuration.

§Type Parameters
  • State - The state type of the actor, which must implement Default, Send, Debug, and have a static lifetime.
§Arguments
  • config - The ActorConfig to use for creating the actor.
§Returns

A ManagedActor in the Idle state with the specified State and configuration.

Source

pub fn broker(&self) -> AgentHandle

Retrieves the broker reference for the system.

§Returns

A clone of the BrokerRef associated with this SystemReady instance.

Source

pub async fn spawn_agent_with_setup_fn<State>( &mut self, config: AgentConfig, setup_fn: impl FnOnce(ManagedAgent<Idle, State>) -> Pin<Box<dyn Future<Output = AgentHandle> + Send + 'static>>, ) -> Result<AgentHandle>
where State: Default + Send + Debug + 'static,

Spawns an actor with a custom setup function and configuration.

§Type Parameters
  • State - The state type of the actor, which must implement Default, Send, Debug, and have a static lifetime.
§Arguments
  • config - The ActorConfig to use for creating the actor.
  • setup_fn - A function that takes a ManagedActor and returns a Future resolving to an ActorRef.
§Returns

A Result containing the ActorRef of the spawned actor, or an error if the spawn failed.

Source

pub async fn shutdown_all(&mut self) -> Result<()>

Shuts down the Acton system, stopping all actors and their children.

Source

pub async fn spawn_actor<State>( &mut self, setup_fn: impl FnOnce(ManagedAgent<Idle, State>) -> Pin<Box<dyn Future<Output = AgentHandle> + Send + 'static>>, ) -> Result<AgentHandle>
where State: Default + Send + Debug + 'static,

Spawns an actor with a custom setup function and default configuration.

§Type Parameters
  • State - The state type of the actor, which must implement Default, Send, Debug, and have a static lifetime.
§Arguments
  • setup_fn - A function that takes a ManagedActor and returns a Future resolving to an ActorRef.
§Returns

A Result containing the ActorRef of the spawned actor, or an error if the spawn failed.

Trait Implementations§

Source§

impl Clone for AgentRuntime

Source§

fn clone(&self) -> AgentRuntime

Returns a copy 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 AgentRuntime

Source§

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

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

impl Default for AgentRuntime

Source§

fn default() -> AgentRuntime

Returns the “default value” for a type. Read more
Source§

impl From<ActonApp> for AgentRuntime

Source§

fn from(_acton: ActonApp) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> ActonMessage for T
where T: Any + Send + Sync + Debug + DynClone + 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Returns a reference to the message as Any.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Returns a mutable reference to the message as Any.
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, dst: *mut u8)

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

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Subscribable for T
where T: ActonMessage + Send + Sync + 'static,

Source§

fn subscribe<M>(&self) -> impl Future<Output = ()> + Send + Sync
where M: ActonMessage + Send + Sync + 'static, T: Actor + Subscriber + 'static,

Subscribes the implementing type to messages of type T. Read more
Source§

fn unsubscribe<M>(&self)
where M: ActonMessage, T: Actor + Subscriber,

Unsubscribes the implementing type from messages of type T. Read more
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