Struct ActorServer

Source
pub struct ActorServer<Actor, Message, State, Response, Error> { /* private fields */ }
Expand description

ActorServer is a structure that represents a server for actors. It contains a reference to an actor.

§Type Parameters

  • Actor: The type of the actor that this server is hosting.
  • Message: The type of the messages that the actor can handle.
  • State: The type of the state that the actor maintains.
  • Response: The type of the response that the actor produces when handling a message.
  • Error: The type of the error that the actor can produce when handling a message.

§Fields

  • actor_ref: A mutex protecting an optional reference to the actor. This allows the actor to be safely shared between multiple threads.
  • failed: …

Trait Implementations§

Source§

impl<Actor: Handler<Actor = Actor, State = State, Message = Message, Error = Error, Response = Response> + SSSDED, Message: SSSDED, State: SSSDED, Response: SSSDED, Error: SSSDED + Error + From<Error> + 'static> ActorServerTrait for ActorServer<Actor, Message, State, Response, Error>

Source§

async fn new( name: impl AsRef<str>, host: impl AsRef<str>, port: u16, actor: Arc<ActorRef<Actor, Message, State, Response, Error>>, ) -> Result<Arc<Self>, Error>

Creates a new instance of ActorServer.

§Arguments
  • name - A string slice that holds the name of the actor server.
  • host - A string slice that holds the host of the actor server.
  • port - A 16-bit unsigned integer that represents the port on which the actor server will run.
  • actor - An Arc reference to an ActorRef object.
§Returns
  • Result<Arc<Self>, Error> - Returns a new instance of ActorServer wrapped in an Arc. If an error occurs, it returns an Error.
§Errors

This function will return an error if the TCP listener fails to bind to the provided address.

Source§

async fn stop(&self) -> Result<(), Error>

Stops the ActorServer.

This method attempts to stop the actor referenced by this server. If the actor reference exists, it will call the stop method on the actor. After attempting to stop the actor, it sets the actor reference to None.

§Returns
  • Result<(), Error> - Returns an empty Result if the operation is successful. If an error occurs while stopping the actor, it returns an Error.
§Errors

This function will return an error if the actor fails to stop.

Source§

type Actor = Actor

Source§

type Message = Message

Source§

type State = State

Source§

type Response = Response

Source§

type Error = Error

Source§

impl<Actor: Debug, Message: Debug, State: Debug, Response: Debug, Error: Debug> Debug for ActorServer<Actor, Message, State, Response, Error>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Actor, Message, State, Response, Error> !Freeze for ActorServer<Actor, Message, State, Response, Error>

§

impl<Actor, Message, State, Response, Error> !RefUnwindSafe for ActorServer<Actor, Message, State, Response, Error>

§

impl<Actor, Message, State, Response, Error> Send for ActorServer<Actor, Message, State, Response, Error>
where Actor: Sync + Send, State: Send, Message: Send, Response: Send, Error: Send,

§

impl<Actor, Message, State, Response, Error> Sync for ActorServer<Actor, Message, State, Response, Error>
where Actor: Sync + Send, State: Send, Message: Send, Response: Send, Error: Send,

§

impl<Actor, Message, State, Response, Error> Unpin for ActorServer<Actor, Message, State, Response, Error>

§

impl<Actor, Message, State, Response, Error> !UnwindSafe for ActorServer<Actor, Message, State, Response, Error>

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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<S> SSSD for S
where S: Send + Sync + Debug + 'static,