Trait tk_http::server::buffered::Service
[−]
[src]
pub trait Service<S> { type Future: Future<Item = EncoderDone<S>, Error = Error>; type WebsocketFuture: Future<Item = (), Error = ()> + 'static; fn call(&mut self, request: Request, encoder: Encoder<S>) -> Self::Future; fn start_websocket(
&mut self,
output: WriteFramed<S, WebsocketCodec>,
input: ReadFramed<S, WebsocketCodec>
) -> Self::WebsocketFuture; }
An instance of a NewService for a single request, usually just a function
Associated Types
type Future: Future<Item = EncoderDone<S>, Error = Error>
A future returned by call()
type WebsocketFuture: Future<Item = (), Error = ()> + 'static
A future returned by start_websocket
, it's spawned on the main loop
hence needed to be static.
Required Methods
fn call(&mut self, request: Request, encoder: Encoder<S>) -> Self::Future
A method which is called when request arrives, including the websocket negotiation request.
See examples for a way to negotiate both websockets and services
fn start_websocket(
&mut self,
output: WriteFramed<S, WebsocketCodec>,
input: ReadFramed<S, WebsocketCodec>
) -> Self::WebsocketFuture
&mut self,
output: WriteFramed<S, WebsocketCodec>,
input: ReadFramed<S, WebsocketCodec>
) -> Self::WebsocketFuture
A method which is called when websocket connection established
Implementors
impl<S, H, I, T, U> Service<S> for WebsocketService<H, I, T, U> where
H: Fn(Request, Encoder<S>) -> T,
I: Fn(WriteFramed<S, WebsocketCodec>, ReadFramed<S, WebsocketCodec>) -> U,
T: Future<Item = EncoderDone<S>, Error = Error>,
U: Future<Item = (), Error = ()> + 'static,impl<S, T, F> Service<S> for T where
T: Fn(Request, Encoder<S>) -> F,
F: Future<Item = EncoderDone<S>, Error = Error>,