1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use crate::message::{Message, Action};
use crate::error::{Error, ApiError};
use crate::server::{Data, Session};
use stream::util::PinnedFuture;
pub trait Request {
type Action: Action;
type Response;
type Error: ApiError;
const ACTION: Self::Action;
}
pub trait RequestHandler<B> {
type Action: Action;
fn action() -> Self::Action
where Self: Sized;
fn validate_data(&self, data: &Data);
fn handle<'a>(
&'a self,
msg: Message<Self::Action, B>,
data: &'a Data,
session: &'a Session
) -> PinnedFuture<'a, Result<Message<Self::Action, B>, Error>>;
}