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>
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>
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- AnArcreference to anActorRefobject.
§Returns
Result<Arc<Self>, Error>- Returns a new instance ofActorServerwrapped in anArc. If an error occurs, it returns anError.
§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>
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 emptyResultif the operation is successful. If an error occurs while stopping the actor, it returns anError.
§Errors
This function will return an error if the actor fails to stop.
type Actor = Actor
type Message = Message
type State = State
type Response = Response
type Error = Error
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>
impl<Actor, Message, State, Response, Error> Sync for ActorServer<Actor, Message, State, Response, Error>
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> 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