pub struct AsyncHandlerGuard<E: Send + Sync + 'static> { /* private fields */ }Available on crate feature
async only.Expand description
RAII handle for a registered async handler.
§Examples
use std::sync::Arc;
use registry_io::r#async::AsyncRegistry;
let registry = Arc::new(AsyncRegistry::<()>::new());
assert!(registry.is_empty());
{
let _guard = registry.register_guard(|_| async move {});
assert_eq!(registry.handler_count(), 1);
}
assert!(registry.is_empty());Implementations§
Source§impl<E: Send + Sync + 'static> AsyncHandlerGuard<E>
impl<E: Send + Sync + 'static> AsyncHandlerGuard<E>
Sourcepub fn id(&self) -> HandlerId
pub fn id(&self) -> HandlerId
Returns the HandlerId of the underlying registration.
§Examples
use std::sync::Arc;
use registry_io::r#async::AsyncRegistry;
let registry = Arc::new(AsyncRegistry::<()>::new());
let guard = registry.register_guard(|_| async move {});
let id = guard.id();
drop(guard);
assert!(!registry.contains(id));Sourcepub fn forget(self)
pub fn forget(self)
Consume the guard without unregistering the handler.
§Examples
use std::sync::Arc;
use registry_io::r#async::AsyncRegistry;
let registry = Arc::new(AsyncRegistry::<()>::new());
let guard = registry.register_guard(|_| async move {});
let id = guard.id();
guard.forget();
assert!(registry.contains(id));
assert!(registry.unregister(id));Trait Implementations§
Auto Trait Implementations§
impl<E> Freeze for AsyncHandlerGuard<E>
impl<E> !RefUnwindSafe for AsyncHandlerGuard<E>
impl<E> Send for AsyncHandlerGuard<E>
impl<E> Sync for AsyncHandlerGuard<E>
impl<E> Unpin for AsyncHandlerGuard<E>
impl<E> UnsafeUnpin for AsyncHandlerGuard<E>
impl<E> !UnwindSafe for AsyncHandlerGuard<E>
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