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
use std::fmt::Debug;
use rustc_serialize::{Encodable, Decodable};
use envelope::Envelope;
use correlation_id::CorrelationId;
use pid::Pid;
pub trait ConnectionHandler : Sized {
type Msg: Encodable + Decodable + Debug + Clone;
type ClientMsg: Debug;
fn new(pid: Pid, id: u64) -> Self;
fn handle_envelope(&mut self, Envelope<Self::Msg>) -> &mut Vec<ConnectionMsg<Self>>;
fn handle_network_msg(&mut self, Self::ClientMsg) -> &mut Vec<ConnectionMsg<Self>>;
}
pub enum ConnectionMsg<C: ConnectionHandler>
{
Envelope(Envelope<C::Msg>),
Client(C::ClientMsg, CorrelationId)
}