forked from lemunozm/message-io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.rs
65 lines (52 loc) · 1.45 KB
/
template.rs
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#![allow(unused_variables)]
use crate::network::adapter::{
Resource, Remote, Local, Adapter, SendStatus, AcceptedType, ReadStatus, ConnectionInfo,
ListeningInfo, PendingStatus,
};
use crate::network::{RemoteAddr, Readiness, TransportConnect, TransportListen};
use mio::event::{Source};
use std::net::{SocketAddr};
use std::io::{self};
pub(crate) struct MyAdapter;
impl Adapter for MyAdapter {
type Remote = RemoteResource;
type Local = LocalResource;
}
pub(crate) struct RemoteResource;
impl Resource for RemoteResource {
fn source(&mut self) -> &mut dyn Source {
todo!()
}
}
impl Remote for RemoteResource {
fn connect_with(
config: TransportConnect,
remote_addr: RemoteAddr,
) -> io::Result<ConnectionInfo<Self>> {
todo!()
}
fn receive(&self, process_data: impl FnMut(&[u8])) -> ReadStatus {
todo!()
}
fn send(&self, data: &[u8]) -> SendStatus {
todo!()
}
fn pending(&self, _readiness: Readiness) -> PendingStatus {
todo!()
}
}
pub(crate) struct LocalResource;
impl Resource for LocalResource {
fn source(&mut self) -> &mut dyn Source {
todo!()
}
}
impl Local for LocalResource {
type Remote = RemoteResource;
fn listen_with(config: TransportListen, addr: SocketAddr) -> io::Result<ListeningInfo<Self>> {
todo!()
}
fn accept(&self, accept_remote: impl FnMut(AcceptedType<'_, Self::Remote>)) {
todo!()
}
}