Trait ActorRefTrait

Source
pub trait ActorRefTrait {
    type Actor: Handler + SSSD;
    type State: SSSD;
    type Error: SSSD + Error + From<Error>;

    // Required methods
    fn new(
        name: impl AsRef<str>,
        actor: Self::Actor,
        state: Self::State,
        buffer: usize,
    ) -> impl Future<Output = Result<Arc<Self>, Self::Error>>;
    fn state(
        &self,
    ) -> impl Future<Output = Result<Arc<Mutex<Self::State>>, Error>>;
}
Expand description

The ActorRefTrait trait defines the behavior of an actor reference in an actor system. It provides methods for creating a new actor reference and getting the state of the actor.

§Type Parameters

  • Actor: The type of the actor this reference points to. It must implement the Handler and SSSD traits.
  • State: The type of the state that the actor maintains. It must implement the SSSD trait.
  • Error: The type of the error that the actor can return. It must implement the SSSD trait and std::error::Error, and be convertible from std::io::Error.

Required Associated Types§

Required Methods§

Source

fn new( name: impl AsRef<str>, actor: Self::Actor, state: Self::State, buffer: usize, ) -> impl Future<Output = Result<Arc<Self>, Self::Error>>

Creates a new actor reference.

This method creates a new actor reference with the given name, actor, state, and buffer size. It returns a future that resolves to a result containing either the new actor reference or an error.

§Parameters
  • name: The name of the actor.
  • actor: The actor that this reference will point to.
  • state: The initial state of the actor.
  • buffer: The size of the message buffer for the actor.
§Returns

A future that resolves to a result containing either a new actor reference or an error.

Source

fn state(&self) -> impl Future<Output = Result<Arc<Mutex<Self::State>>, Error>>

Gets the state of the actor.

This method returns a future that resolves to a result containing either the state of the actor or an error.

§Returns

A future that resolves to a result containing either the state of the actor or an error.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<Actor: Handler<Actor = Actor, State = State, Message = Message, Error = Error, Response = Response> + SSSD, Message: SSSD, State: SSSD, Response: SSSD, Error: SSSD + Error + From<Error>> ActorRefTrait for ActorRef<Actor, Message, State, Response, Error>

Implementation of the ActorRefTrait for ActorRef.

This implementation provides the functionality for creating a new actor reference (new method), and for getting the state of the actor (state method).

§Type Parameters

  • Actor: The type of the actor this reference points to. It must implement the Handler and SSSD traits.
  • Message: The type of messages that this actor can process. It must implement the SSSD trait.
  • State: The type of the state that the actor maintains. It must implement the SSSD trait.
  • Response: The type of the response that the actor produces. It must implement the SSSD trait.
  • Error: The type of the error that the actor can return. It must implement the SSSD trait and std::error::Error, and be convertible from std::io::Error.
Source§

type Actor = Actor

Source§

type State = State

Source§

type Error = Error