Trait Server

Source
pub trait Server {
    type Request;
    type Response;
    type Key;
    type Error;

    // Required methods
    fn poll_for_request(
        &mut self,
    ) -> Result<Option<(Self::Key, Self::Request)>, Self::Error>;
    fn poll_for_requests(
        &mut self,
    ) -> Vec<Result<(Self::Key, Self::Request), Self::Error>>;
    fn send_response(
        &mut self,
        client_key: Self::Key,
        request: Self::Request,
        response: Self::Response,
    ) -> Result<(), Self::Error>;

    // Provided method
    fn send_responses(
        &mut self,
        responses: Vec<(Self::Key, Self::Request, Self::Response)>,
    ) -> Vec<Result<(), Self::Error>> { ... }
}
Expand description

A common abstraction for all NComm servers that outlines the necessary base requirements for all NComm servers

Required Associated Types§

Source

type Request

The type of data received as a request from the client

Source

type Response

The type of data sent as a response to the client

Source

type Key

The unique identifier type for the various clients

Source

type Error

The type of error from sending or receiving data from the client

Required Methods§

Source

fn poll_for_request( &mut self, ) -> Result<Option<(Self::Key, Self::Request)>, Self::Error>

Check for an incoming request from the client

Source

fn poll_for_requests( &mut self, ) -> Vec<Result<(Self::Key, Self::Request), Self::Error>>

Check for incoming requests from the client

Source

fn send_response( &mut self, client_key: Self::Key, request: Self::Request, response: Self::Response, ) -> Result<(), Self::Error>

Send a response to a specific client

Provided Methods§

Source

fn send_responses( &mut self, responses: Vec<(Self::Key, Self::Request, Self::Response)>, ) -> Vec<Result<(), Self::Error>>

Send a collection of responses to specified clients

Implementors§