21
21
22
22
//! Untyped pointer that can be cast to any struct, list, or capability type.
23
23
24
- use alloc:: boxed :: Box ;
25
- use alloc:: vec:: Vec ;
24
+ # [ cfg ( feature = " alloc" ) ]
25
+ use alloc:: { boxed :: Box , vec:: Vec } ;
26
26
27
+ #[ cfg( feature = "alloc" ) ]
27
28
use crate :: capability:: FromClientHook ;
29
+ #[ cfg( feature = "alloc" ) ]
28
30
use crate :: private:: capability:: { ClientHook , PipelineHook , PipelineOp } ;
29
31
use crate :: private:: layout:: { PointerBuilder , PointerReader } ;
30
32
use crate :: traits:: { FromPointerBuilder , FromPointerReader , SetPointerBuilder } ;
@@ -44,6 +46,7 @@ impl crate::introspect::Introspect for Owned {
44
46
}
45
47
}
46
48
49
+ #[ cfg( feature = "alloc" ) ]
47
50
impl crate :: traits:: Pipelined for Owned {
48
51
type Pipeline = Pipeline ;
49
52
}
@@ -73,12 +76,14 @@ impl<'a> Reader<'a> {
73
76
FromPointerReader :: get_from_pointer ( & self . reader , None )
74
77
}
75
78
79
+ #[ cfg( feature = "alloc" ) ]
76
80
pub fn get_as_capability < T : FromClientHook > ( & self ) -> Result < T > {
77
81
Ok ( FromClientHook :: new ( self . reader . get_capability ( ) ?) )
78
82
}
79
83
80
84
//# Used by RPC system to implement pipelining. Applications
81
85
//# generally shouldn't use this directly.
86
+ #[ cfg( feature = "alloc" ) ]
82
87
pub fn get_pipelined_cap ( & self , ops : & [ PipelineOp ] ) -> Result < Box < dyn ClientHook > > {
83
88
let mut pointer = self . reader ;
84
89
@@ -117,6 +122,7 @@ impl<'a> crate::traits::SetPointerBuilder for Reader<'a> {
117
122
}
118
123
}
119
124
125
+ #[ cfg( feature = "alloc" ) ]
120
126
impl < ' a > crate :: traits:: Imbue < ' a > for Reader < ' a > {
121
127
fn imbue ( & mut self , cap_table : & ' a crate :: private:: layout:: CapTable ) {
122
128
self . reader
@@ -165,6 +171,7 @@ impl<'a> Builder<'a> {
165
171
}
166
172
167
173
// XXX value should be a user client.
174
+ #[ cfg( feature = "alloc" ) ]
168
175
pub fn set_as_capability ( & mut self , value : Box < dyn ClientHook > ) {
169
176
self . builder . set_capability ( value) ;
170
177
}
@@ -199,20 +206,23 @@ impl<'a> FromPointerBuilder<'a> for Builder<'a> {
199
206
}
200
207
}
201
208
209
+ #[ cfg( feature = "alloc" ) ]
202
210
impl < ' a > crate :: traits:: ImbueMut < ' a > for Builder < ' a > {
203
211
fn imbue_mut ( & mut self , cap_table : & ' a mut crate :: private:: layout:: CapTable ) {
204
212
self . builder
205
213
. imbue ( crate :: private:: layout:: CapTableBuilder :: Plain ( cap_table) ) ;
206
214
}
207
215
}
208
216
217
+ #[ cfg( feature = "alloc" ) ]
209
218
pub struct Pipeline {
210
219
// XXX this should not be public
211
220
pub hook : Box < dyn PipelineHook > ,
212
221
213
222
ops : Vec < PipelineOp > ,
214
223
}
215
224
225
+ #[ cfg( feature = "alloc" ) ]
216
226
impl Pipeline {
217
227
pub fn new ( hook : Box < dyn PipelineHook > ) -> Self {
218
228
Self {
@@ -245,24 +255,28 @@ impl Pipeline {
245
255
}
246
256
}
247
257
258
+ #[ cfg( feature = "alloc" ) ]
248
259
impl crate :: capability:: FromTypelessPipeline for Pipeline {
249
260
fn new ( typeless : Pipeline ) -> Self {
250
261
typeless
251
262
}
252
263
}
253
264
265
+ #[ cfg( feature = "alloc" ) ]
254
266
impl < ' a > From < Reader < ' a > > for crate :: dynamic_value:: Reader < ' a > {
255
267
fn from ( a : Reader < ' a > ) -> crate :: dynamic_value:: Reader < ' a > {
256
268
crate :: dynamic_value:: Reader :: AnyPointer ( a)
257
269
}
258
270
}
259
271
272
+ #[ cfg( feature = "alloc" ) ]
260
273
impl < ' a > From < Builder < ' a > > for crate :: dynamic_value:: Builder < ' a > {
261
274
fn from ( a : Builder < ' a > ) -> crate :: dynamic_value:: Builder < ' a > {
262
275
crate :: dynamic_value:: Builder :: AnyPointer ( a)
263
276
}
264
277
}
265
278
279
+ #[ cfg( feature = "alloc" ) ]
266
280
#[ test]
267
281
fn init_clears_value ( ) {
268
282
let mut message = crate :: message:: Builder :: new_default ( ) ;
0 commit comments