Skip to main content

ConnectionHandler

Trait ConnectionHandler 

Source
pub trait ConnectionHandler: Send + 'static {
    type Action: Debug + Send + 'static;
    type Event: Debug + Send + 'static;

    // Required methods
    fn handle_action(&mut self, action: Self::Action);
    fn poll(
        &mut self,
        cx: &mut Context<'_>,
    ) -> Poll<ConnectionHandlerEvent<Self::Event>>;

    // Provided methods
    fn connection_keep_alive(&self) -> bool { ... }
    fn poll_close(&mut self, _: &mut Context<'_>) -> Poll<Option<Self::Event>> { ... }
    fn select<H>(self, other: H) -> ConnectionHandlerSelect<Self, H>
       where H: ConnectionHandler,
             Self: Sized { ... }
    fn map_event<O, F>(self, map: F) -> MapEvent<Self, F>
       where Self: Sized,
             O: Debug + Send + 'static,
             F: FnMut(Self::Event) -> O + Send + 'static { ... }
    fn map_action<O, F>(self, map: F) -> MapAction<Self, O, F>
       where Self: Sized,
             O: Debug + Send + 'static,
             F: FnMut(O) -> Option<Self::Action> + Send + 'static { ... }
}

Required Associated Types§

Source

type Action: Debug + Send + 'static

Source

type Event: Debug + Send + 'static

Required Methods§

Source

fn handle_action(&mut self, action: Self::Action)

Source

fn poll( &mut self, cx: &mut Context<'_>, ) -> Poll<ConnectionHandlerEvent<Self::Event>>

Provided Methods§

Source

fn connection_keep_alive(&self) -> bool

Source

fn poll_close(&mut self, _: &mut Context<'_>) -> Poll<Option<Self::Event>>

Source

fn select<H>(self, other: H) -> ConnectionHandlerSelect<Self, H>
where H: ConnectionHandler, Self: Sized,

Source

fn map_event<O, F>(self, map: F) -> MapEvent<Self, F>
where Self: Sized, O: Debug + Send + 'static, F: FnMut(Self::Event) -> O + Send + 'static,

Source

fn map_action<O, F>(self, map: F) -> MapAction<Self, O, F>
where Self: Sized, O: Debug + Send + 'static, F: FnMut(O) -> Option<Self::Action> + Send + 'static,

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl ConnectionHandler for DummyHandler

Source§

impl ConnectionHandler for PendingConnectionHandler

Source§

impl<L, R> ConnectionHandler for Either<L, R>

Source§

impl<THandler1, THandler2> ConnectionHandler for ConnectionHandlerSelect<THandler1, THandler2>
where THandler1: ConnectionHandler, THandler2: ConnectionHandler,

Source§

type Action = Either<<THandler1 as ConnectionHandler>::Action, <THandler2 as ConnectionHandler>::Action>

Source§

type Event = Either<<THandler1 as ConnectionHandler>::Event, <THandler2 as ConnectionHandler>::Event>

Source§

impl<THandler, O, TMap> ConnectionHandler for MapAction<THandler, O, TMap>
where THandler: ConnectionHandler, O: Debug + Send + Clone + 'static, TMap: Send + 'static + Fn(O) -> Option<THandler::Action>,

Source§

type Action = O

Source§

type Event = <THandler as ConnectionHandler>::Event

Source§

impl<THandler, O, TMap> ConnectionHandler for MapEvent<THandler, TMap>
where THandler: ConnectionHandler, O: Debug + Send + Clone + 'static, TMap: Send + 'static + FnMut(THandler::Event) -> O,