Trait UpdateServer

Source
pub trait UpdateServer {
    type Request: Clone;
    type Update;
    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_update(
        &mut self,
        client_key: Self::Key,
        request: &Self::Request,
        update: Self::Update,
    ) -> Result<(), Self::Error>;
    fn send_response(
        &mut self,
        client_key: Self::Key,
        request: Self::Request,
        response: Self::Response,
    ) -> Result<(), Self::Error>;

    // Provided methods
    fn send_updates(
        &mut self,
        updates: Vec<(Self::Key, &Self::Request, Self::Update)>,
    ) -> Vec<Result<(), Self::Error>> { ... }
    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 update servers

Required Associated Types§

Source

type Request: Clone

The type of data received as a request from the client

Source

type Update

The type of data sent as an update to 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 and to the update client

Required Methods§

Source

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

Check for a singular 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_update( &mut self, client_key: Self::Key, request: &Self::Request, update: Self::Update, ) -> Result<(), Self::Error>

Send an update to a specific 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_updates( &mut self, updates: Vec<(Self::Key, &Self::Request, Self::Update)>, ) -> Vec<Result<(), Self::Error>>

Send a collection of updates to specified client

Source

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

Send a collection of responses to specific clients

Implementors§