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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
use alloc::boxed::Box;
use alloc::vec::Vec;
use crate::any_pointer;
use crate::MessageSize;
use crate::capability::{Params, Promise, Request, RemotePromise, Results};
pub trait ResponseHook {
fn get<'a>(&'a self) -> crate::Result<any_pointer::Reader<'a>>;
}
pub trait RequestHook {
fn get<'a>(&'a mut self) -> any_pointer::Builder<'a>;
fn get_brand(&self) -> usize;
fn send(self: Box<Self>) -> RemotePromise<any_pointer::Owned>;
fn tail_send(self: Box<Self>)
-> Option<(u32, crate::capability::Promise<(), crate::Error>, Box<dyn PipelineHook>)>;
}
pub trait ClientHook {
fn add_ref(&self) -> Box<dyn ClientHook>;
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,
params: Box<dyn ParamsHook>, results: Box<dyn ResultsHook>)
-> crate::capability::Promise<(), crate::Error>;
fn get_brand(&self) -> usize;
fn get_ptr(&self) -> usize;
fn get_resolved(&self) -> Option<Box<dyn ClientHook>>;
fn when_more_resolved(&self) -> Option<crate::capability::Promise<Box<dyn ClientHook>, crate::Error>>;
fn when_resolved(&self) -> Promise<(), crate::Error>;
}
impl Clone for Box<dyn ClientHook> {
fn clone(&self) -> Box<dyn ClientHook> {
self.add_ref()
}
}
pub trait ResultsHook {
fn get<'a>(&'a mut self) -> crate::Result<any_pointer::Builder<'a>>;
fn allow_cancellation(&self);
fn tail_call(self: Box<Self>, request: Box<dyn RequestHook>) -> Promise<(), crate::Error>;
fn direct_tail_call(self: Box<Self>, request: Box<dyn RequestHook>) ->
(crate::capability::Promise<(), crate::Error>, Box<dyn PipelineHook>);
}
pub trait ParamsHook {
fn get<'a>(&'a self) -> crate::Result<crate::any_pointer::Reader<'a>>;
}
pub fn internal_get_typed_params<T>(typeless: Params<any_pointer::Owned>) -> Params<T> {
Params { hook: typeless.hook, marker: ::core::marker::PhantomData }
}
pub fn internal_get_typed_results<T>(typeless: Results<any_pointer::Owned>) -> Results<T> {
Results { hook: typeless.hook, marker: ::core::marker::PhantomData }
}
pub fn internal_get_untyped_results<T>(typeful: Results<T>) -> Results<any_pointer::Owned> {
Results { hook: typeful.hook, marker: ::core::marker::PhantomData }
}
pub trait PipelineHook {
fn add_ref(&self) -> Box<dyn PipelineHook>;
fn get_pipelined_cap(&self, ops: &[PipelineOp]) -> Box<dyn ClientHook>;
fn get_pipelined_cap_move(&self, ops: Vec<PipelineOp>) -> Box<dyn ClientHook> {
self.get_pipelined_cap(&ops)
}
}
impl Clone for Box<dyn PipelineHook> {
fn clone(&self) -> Box<dyn PipelineHook> {
self.add_ref()
}
}
#[derive(Clone, Copy)]
pub enum PipelineOp {
Noop,
GetPointerField(u16),
}