2121
2222//! Untyped pointer that can be cast to any struct, list, or capability type.
2323
24- use alloc:: boxed :: Box ;
25- use alloc:: vec:: Vec ;
24+ # [ cfg ( feature = " alloc" ) ]
25+ use alloc:: { boxed :: Box , vec:: Vec } ;
2626
27+ #[ cfg( feature = "alloc" ) ]
2728use crate :: capability:: FromClientHook ;
29+ #[ cfg( feature = "alloc" ) ]
2830use crate :: private:: capability:: { ClientHook , PipelineHook , PipelineOp } ;
2931use crate :: private:: layout:: { PointerBuilder , PointerReader } ;
3032use crate :: traits:: { FromPointerBuilder , FromPointerReader , SetPointerBuilder } ;
@@ -44,6 +46,7 @@ impl crate::introspect::Introspect for Owned {
4446 }
4547}
4648
49+ #[ cfg( feature = "alloc" ) ]
4750impl crate :: traits:: Pipelined for Owned {
4851 type Pipeline = Pipeline ;
4952}
@@ -73,12 +76,14 @@ impl<'a> Reader<'a> {
7376 FromPointerReader :: get_from_pointer ( & self . reader , None )
7477 }
7578
79+ #[ cfg( feature = "alloc" ) ]
7680 pub fn get_as_capability < T : FromClientHook > ( & self ) -> Result < T > {
7781 Ok ( FromClientHook :: new ( self . reader . get_capability ( ) ?) )
7882 }
7983
8084 //# Used by RPC system to implement pipelining. Applications
8185 //# generally shouldn't use this directly.
86+ #[ cfg( feature = "alloc" ) ]
8287 pub fn get_pipelined_cap ( & self , ops : & [ PipelineOp ] ) -> Result < Box < dyn ClientHook > > {
8388 let mut pointer = self . reader ;
8489
@@ -117,6 +122,7 @@ impl<'a> crate::traits::SetPointerBuilder for Reader<'a> {
117122 }
118123}
119124
125+ #[ cfg( feature = "alloc" ) ]
120126impl < ' a > crate :: traits:: Imbue < ' a > for Reader < ' a > {
121127 fn imbue ( & mut self , cap_table : & ' a crate :: private:: layout:: CapTable ) {
122128 self . reader
@@ -165,6 +171,7 @@ impl<'a> Builder<'a> {
165171 }
166172
167173 // XXX value should be a user client.
174+ #[ cfg( feature = "alloc" ) ]
168175 pub fn set_as_capability ( & mut self , value : Box < dyn ClientHook > ) {
169176 self . builder . set_capability ( value) ;
170177 }
@@ -199,20 +206,23 @@ impl<'a> FromPointerBuilder<'a> for Builder<'a> {
199206 }
200207}
201208
209+ #[ cfg( feature = "alloc" ) ]
202210impl < ' a > crate :: traits:: ImbueMut < ' a > for Builder < ' a > {
203211 fn imbue_mut ( & mut self , cap_table : & ' a mut crate :: private:: layout:: CapTable ) {
204212 self . builder
205213 . imbue ( crate :: private:: layout:: CapTableBuilder :: Plain ( cap_table) ) ;
206214 }
207215}
208216
217+ #[ cfg( feature = "alloc" ) ]
209218pub struct Pipeline {
210219 // XXX this should not be public
211220 pub hook : Box < dyn PipelineHook > ,
212221
213222 ops : Vec < PipelineOp > ,
214223}
215224
225+ #[ cfg( feature = "alloc" ) ]
216226impl Pipeline {
217227 pub fn new ( hook : Box < dyn PipelineHook > ) -> Self {
218228 Self {
@@ -245,24 +255,28 @@ impl Pipeline {
245255 }
246256}
247257
258+ #[ cfg( feature = "alloc" ) ]
248259impl crate :: capability:: FromTypelessPipeline for Pipeline {
249260 fn new ( typeless : Pipeline ) -> Self {
250261 typeless
251262 }
252263}
253264
265+ #[ cfg( feature = "alloc" ) ]
254266impl < ' a > From < Reader < ' a > > for crate :: dynamic_value:: Reader < ' a > {
255267 fn from ( a : Reader < ' a > ) -> crate :: dynamic_value:: Reader < ' a > {
256268 crate :: dynamic_value:: Reader :: AnyPointer ( a)
257269 }
258270}
259271
272+ #[ cfg( feature = "alloc" ) ]
260273impl < ' a > From < Builder < ' a > > for crate :: dynamic_value:: Builder < ' a > {
261274 fn from ( a : Builder < ' a > ) -> crate :: dynamic_value:: Builder < ' a > {
262275 crate :: dynamic_value:: Builder :: AnyPointer ( a)
263276 }
264277}
265278
279+ #[ cfg( feature = "alloc" ) ]
266280#[ test]
267281fn init_clears_value ( ) {
268282 let mut message = crate :: message:: Builder :: new_default ( ) ;
0 commit comments