ServerChain

Struct ServerChain 

Source
pub struct ServerChain(/* private fields */);
Expand description

A server that chains several other servers.

This composes multiple servers into one. When a notification or an rpc comes, it tries one by one and passes the call to each of them. If the server provides an answer, the iteration is stopped and that answer is returned. If the server refuses the given method name, another server in the chain is tried, until one is found or we run out of servers.

Initialization is called on all the servers.

The AbstractServer is one of the ways to plug servers with incompatible future and success types inside.

Implementations§

Source§

impl ServerChain

Source

pub fn new(subservers: Vec<BoxServer>) -> Self

Construct a new server.

Source

pub fn into_inner(self) -> Vec<BoxServer>

Consume the server and return the subservers inside.

Trait Implementations§

Source§

impl Server for ServerChain

Source§

type Success = Value

The successfull result of the RPC call.
Source§

type RpcCallResult = Box<dyn Future<Item = Value, Error = RpcError>>

The result of the RPC call Read more
Source§

type NotificationResult = Box<dyn Future<Item = (), Error = ()>>

The result of the RPC call. Read more
Source§

fn rpc( &self, ctl: &ServerCtl, method: &str, params: &Option<Value>, ) -> Option<Self::RpcCallResult>

Called when the client requests something. Read more
Source§

fn notification( &self, ctl: &ServerCtl, method: &str, params: &Option<Value>, ) -> Option<Self::NotificationResult>

Called when the client sends a notification. Read more
Source§

fn initialized(&self, ctl: &ServerCtl)

Called when the endpoint is initialized. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.