pub struct CallbackManager<T> { /* private fields */ }Expand description
Synchronous manager of one-time callback functions that are allocated on the heap
Implementations§
Source§impl<T> CallbackManager<T>
impl<T> CallbackManager<T>
Sourcepub fn add_callback(
&mut self,
id: u32,
callback: impl FnOnce(&T) + Send + 'static,
)
pub fn add_callback( &mut self, id: u32, callback: impl FnOnce(&T) + Send + 'static, )
Adds a new callback, associated with the given id
Sourcepub fn take_callback(&mut self, id: u32) -> Option<Box<dyn FnOnce(&T) + Send>>
pub fn take_callback(&mut self, id: u32) -> Option<Box<dyn FnOnce(&T) + Send>>
Retrieves the callback with the associated id, but does not invoke it
Sourcepub fn invoke_callback(&mut self, id: u32, input: &T)
pub fn invoke_callback(&mut self, id: u32, input: &T)
Retrieves and invokes the callback with the associated id
Trait Implementations§
Source§impl<T> Debug for CallbackManager<T>
impl<T> Debug for CallbackManager<T>
Auto Trait Implementations§
impl<T> Freeze for CallbackManager<T>
impl<T> !RefUnwindSafe for CallbackManager<T>
impl<T> Send for CallbackManager<T>
impl<T> !Sync for CallbackManager<T>
impl<T> Unpin for CallbackManager<T>
impl<T> UnsafeUnpin for CallbackManager<T>
impl<T> !UnwindSafe for CallbackManager<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