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;
// Required methods
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<'_>;
// Provided method
fn channel_queue_size() -> usize { ... }
}
Expand description
The GenServer
trait lets you generate a server, by implementing the trait.
Required Associated Types§
Sourcetype Registry
type Registry
Specifies the name of the registry type created with make_registry
.
Sourcetype 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.
Sourcetype 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§
Sourcefn new(registry: Self::Registry) -> Self
fn new(registry: Self::Registry) -> Self
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.
Sourcefn 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.
Sourcefn 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.
Provided Methods§
Sourcefn channel_queue_size() -> usize
fn channel_queue_size() -> usize
Reimplement this method to change the channel queue size for your server. Defaults to 1000 messages.
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.