pub trait GenServer {
type Message;
type Response;
type Registry;
type CallResponse<'a>: Future<Output = Self::Response>
where
Self: 'a;
type CastResponse<'a>: Future<Output = ()>
where
Self: 'a;
fn new(registry: Self::Registry) -> Self;
fn handle_call(&mut self, message: Self::Message) -> Self::CallResponse<'_>;
fn handle_cast(&mut self, message: Self::Message) -> Self::CastResponse<'_>;
}
Expand description
The GenServer
trait lets you generate a server, by implementing the trait.
Required Associated Types
Specifies the name of the registry type created with make_registry
.
type CallResponse<'a>: Future<Output = Self::Response>
where
Self: 'a
type CallResponse<'a>: Future<Output = Self::Response>
where
Self: 'a
Specifies the call response type, which must implement std::future::Future.
type CastResponse<'a>: Future<Output = ()>
where
Self: 'a
type CastResponse<'a>: Future<Output = ()>
where
Self: 'a
Specifies the call response type, which must implement
std::future::Future and return ()
.
Required Methods
Creates a new server, and receives a copy of the current registry.
You should never need to call this method yourself, as it’s called for you by the registry.
fn handle_call(&mut self, message: Self::Message) -> Self::CallResponse<'_>
fn handle_call(&mut self, message: Self::Message) -> Self::CallResponse<'_>
This function will be called whenever this server receives a call.
fn handle_cast(&mut self, message: Self::Message) -> Self::CastResponse<'_>
fn handle_cast(&mut self, message: Self::Message) -> Self::CastResponse<'_>
This function will be called whenever this server receives a cast.