pub struct Callback { /* private fields */ }Expand description
An owned callback reference. Neither this type nor its borrowed views can cross threads. Reentrant invocation returns Busy before borrowing the closure.
Implementations§
Source§impl Callback
impl Callback
Sourcepub fn new<F>(callback: F) -> Self
pub fn new<F>(callback: F) -> Self
Allocate one callback context. Cloning it retains that same context. Captures own their state and may outlive the plugin call that receives it.
Sourcepub unsafe fn from_raw(raw: RawCallback) -> Result<Self>
pub unsafe fn from_raw(raw: RawCallback) -> Result<Self>
Adopt one already-retained reference.
§Safety
The context, vtable, and origin code must stay valid until all clones have been released. Calls, retain, and release use the origin thread and cannot unwind across the ABI. The origin cooperatively retains its library while callbacks exist, or its code is permanently mapped. On validation failure the caller remains responsible for the unknown ownership.
pub fn as_ref(&self) -> CallbackRef<'_>
pub fn call(&mut self, input: &[u8], output: &mut [u8]) -> Result<usize>
pub fn try_clone(&self) -> Result<Self>
Sourcepub fn into_raw(self) -> RawCallback
pub fn into_raw(self) -> RawCallback
Transfer one retained reference, to be released exactly once.
Trait Implementations§
Auto Trait Implementations§
impl !Send for Callback
impl !Sync for Callback
impl Forget for Callback
impl Freeze for Callback
impl Move for Callback
impl RefUnwindSafe for Callback
impl Unpin for Callback
impl UnsafeUnpin for Callback
impl UnwindSafe for Callback
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