pub struct TokenRegistry<T> { /* private fields */ }Expand description
Waiting closures keyed by token: the shape behind every platform completion that crosses an FFI boundary as a number (docs/bridge.md “Callbacks”).
Rules that make it safe to hand a token to code in another language:
- Register before the call goes out. A platform may complete synchronously, or fail before returning; a slot that exists first is found either way.
- An unknown token is a no-op. A late, duplicate, or cancelled completion finds nothing and does nothing.
- Deliver outside the lock. The closure may register a new token or drop a handle; the registry is never held while it runs.
const-constructible, so a generated static can own one per declaration.
Implementations§
Source§impl<T> TokenRegistry<T>
impl<T> TokenRegistry<T>
Sourcepub fn complete(&self, token: u64, value: T) -> bool
pub fn complete(&self, token: u64, value: T) -> bool
Remove the closure for token and run it with value. false when no closure waits
under that token (completed, cancelled, or never registered).
Trait Implementations§
Auto Trait Implementations§
impl<T> !Freeze for TokenRegistry<T>
impl<T> RefUnwindSafe for TokenRegistry<T>
impl<T> Send for TokenRegistry<T>
impl<T> Sync for TokenRegistry<T>
impl<T> Unpin for TokenRegistry<T>
impl<T> UnsafeUnpin for TokenRegistry<T>
impl<T> UnwindSafe for TokenRegistry<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more