@@ -316,92 +316,21 @@ where
316
316
) ) )
317
317
}
318
318
319
- /// Allows a server to recognize its own capabilities when passed back to it, and obtain the
320
- /// underlying Server objects associated with them.
321
- /// Note that `CapabilityServerSet` holds references to every `Server` passed to it,
322
- /// and the only way to drop them is to drop the entire `CapabilityServerSet`.
323
- /// The `WeakCapabilityServerSet` struct below is a (better) alternative that only holds
324
- /// weak references. Its semantics match the capnproto-c++ version of `CapabilityServerSet`.
325
- ///
326
- /// TODO(v0.17): remove this `CapabilityServerSet` implementation and rename
327
- /// `WeakCapabilityServerSet` to `CapabilityServerSet`.
328
- pub struct CapabilityServerSet < S , C >
329
- where
330
- C : capnp:: capability:: FromServer < S > ,
331
- {
332
- caps : std:: collections:: HashMap < usize , Rc < RefCell < C :: Dispatch > > > ,
333
- }
334
-
335
- impl < S , C > Default for CapabilityServerSet < S , C >
336
- where
337
- C : capnp:: capability:: FromServer < S > ,
338
- {
339
- fn default ( ) -> Self {
340
- Self {
341
- caps : std:: default:: Default :: default ( ) ,
342
- }
343
- }
344
- }
345
-
346
- impl < S , C > CapabilityServerSet < S , C >
347
- where
348
- C : capnp:: capability:: FromServer < S > ,
349
- {
350
- pub fn new ( ) -> Self {
351
- Self :: default ( )
352
- }
353
-
354
- /// Adds a new capability to the set and returns a client backed by it.
355
- pub fn new_client ( & mut self , s : S ) -> C {
356
- let dispatch = <C as capnp:: capability:: FromServer < S > >:: from_server ( s) ;
357
- let wrapped = Rc :: new ( RefCell :: new ( dispatch) ) ;
358
- let ptr = wrapped. as_ptr ( ) as usize ;
359
- self . caps . insert ( ptr, wrapped. clone ( ) ) ;
360
- capnp:: capability:: FromClientHook :: new ( Box :: new ( local:: Client :: from_rc ( wrapped) ) )
361
- }
362
-
363
- /// Looks up a capability and returns its underlying server object, if found.
364
- /// Fully resolves the capability before looking it up.
365
- pub async fn get_local_server ( & self , client : & C ) -> Option < & Rc < RefCell < C :: Dispatch > > >
366
- where
367
- C : capnp:: capability:: FromClientHook ,
368
- {
369
- let resolved: C = capnp:: capability:: get_resolved_cap (
370
- capnp:: capability:: FromClientHook :: new ( client. as_client_hook ( ) . add_ref ( ) ) ,
371
- )
372
- . await ;
373
- let hook = resolved. into_client_hook ( ) ;
374
- let ptr = hook. get_ptr ( ) ;
375
- self . caps . get ( & ptr)
376
- }
377
-
378
- /// Looks up a capability and returns its underlying server object, if found.
379
- /// Does *not* attempt to resolve the capability first, so you will usually want
380
- /// to call `get_resolved_cap()` before calling this. The advantage of this method
381
- /// over `get_local_server()` is that this one is synchronous and borrows `self`
382
- /// over a shorter span (which can be very important if `self` is inside a `RefCell`).
383
- pub fn get_local_server_of_resolved ( & self , client : & C ) -> Option < & Rc < RefCell < C :: Dispatch > > >
384
- where
385
- C : capnp:: capability:: FromClientHook ,
386
- {
387
- let hook = client. as_client_hook ( ) ;
388
- let ptr = hook. get_ptr ( ) ;
389
- self . caps . get ( & ptr)
390
- }
391
- }
319
+ #[ deprecated( since = "0.17.0" , note = "use CapabilityServerSet instead" ) ]
320
+ pub type WeakCapabilityServerSet < S , C > = CapabilityServerSet < S , C > ;
392
321
393
322
/// Allows a server to recognize its own capabilities when passed back to it, and obtain the
394
323
/// underlying Server objects associated with them. Holds only weak references to Server objects
395
324
/// allowing Server objects to be dropped when dropped by the remote client. Call the `gc` method
396
325
/// to reclaim memory used for Server objects that have been dropped.
397
- pub struct WeakCapabilityServerSet < S , C >
326
+ pub struct CapabilityServerSet < S , C >
398
327
where
399
328
C : capnp:: capability:: FromServer < S > ,
400
329
{
401
330
caps : std:: collections:: HashMap < usize , Weak < RefCell < C :: Dispatch > > > ,
402
331
}
403
332
404
- impl < S , C > Default for WeakCapabilityServerSet < S , C >
333
+ impl < S , C > Default for CapabilityServerSet < S , C >
405
334
where
406
335
C : capnp:: capability:: FromServer < S > ,
407
336
{
@@ -412,7 +341,7 @@ where
412
341
}
413
342
}
414
343
415
- impl < S , C > WeakCapabilityServerSet < S , C >
344
+ impl < S , C > CapabilityServerSet < S , C >
416
345
where
417
346
C : capnp:: capability:: FromServer < S > ,
418
347
{
0 commit comments