Trait genserver::GenServer

source ·
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§

source

type Message

Specifies the type of messages this server can receive.

source

type Response

Specifies the response from calls.

source

type Registry

Specifies the name of the registry type created with make_registry.

source

type CallResponse<'a>: Future<Output = Self::Response> where Self: 'a

Specifies the call response type, which must implement std::future::Future.

source

type CastResponse<'a>: Future<Output = ()> where Self: 'a

Specifies the call response type, which must implement std::future::Future and return ().

Required Methods§

source

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.

source

fn handle_call(&mut self, message: Self::Message) -> Self::CallResponse<'_>

This function will be called whenever this server receives a call.

source

fn handle_cast(&mut self, message: Self::Message) -> Self::CastResponse<'_>

This function will be called whenever this server receives a cast.

Provided Methods§

source

fn channel_queue_size() -> usize

Reimplement this method to change the channel queue size for your server. Defaults to 1000 messages.

Implementors§