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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
use any_pointer;
use MessageSize;
use capability::{CallContext, Request, ResultFuture, Server};
pub trait ResponseHook:Send + ::std::any::Any {
fn get<'a>(&'a mut self) -> any_pointer::Reader<'a>;
}
pub trait RequestHook {
fn message<'a>(&'a mut self) -> &'a mut ::message::Builder<::message::HeapAllocator>;
fn send<'a>(self : Box<Self>) -> ResultFuture<any_pointer::Owned>;
}
pub trait ClientHook : Send + ::std::any::Any {
fn copy(&self) -> Box<ClientHook+Send>;
fn new_call(&self,
interface_id : u64,
method_id : u16,
size_hint : Option<MessageSize>)
-> Request<any_pointer::Owned, any_pointer::Owned>;
fn call(&self, interface_id : u64, method_id : u16, context : Box<CallContextHook+Send>);
fn get_descriptor(&self) -> Box<::std::any::Any>;
}
pub trait ServerHook : 'static {
fn new_client(server : Box<Server+Send>) -> Client;
}
pub struct Client {
pub hook : Box<ClientHook+Send>
}
impl Client {
pub fn new(hook : Box<ClientHook+Send>) -> Client {
Client { hook : hook }
}
pub fn new_call<Params, Results>(&self,
interface_id : u64,
method_id : u16,
size_hint : Option<MessageSize>)
-> Request<Params, Results> {
let typeless = self.hook.new_call(interface_id, method_id, size_hint);
Request { hook : typeless.hook, marker : ::std::marker::PhantomData }
}
}
pub trait CallContextHook {
fn get<'a>(&'a mut self) -> (any_pointer::Reader<'a>, any_pointer::Builder<'a>);
fn fail(self : Box<Self>, message : String);
fn done(self : Box<Self>);
}
pub fn internal_get_typed_context<Params, Results>(
typeless : CallContext<any_pointer::Reader, any_pointer::Builder>)
-> CallContext<Params, Results> {
CallContext { hook : typeless.hook, marker : ::std::marker::PhantomData }
}
pub trait PipelineHook {
fn copy(&self) -> Box<PipelineHook+Send>;
fn get_pipelined_cap(&self, ops : Vec<PipelineOp>) -> Box<ClientHook+Send>;
}
#[derive(Clone, Copy)]
pub enum PipelineOp {
Noop,
GetPointerField(u16),
}