Skip to main content

Callback

Struct Callback 

Source
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

Source

pub fn new<F>(callback: F) -> Self
where F: FnMut(&[u8], &mut [u8]) -> Result<usize> + 'static,

Allocate one callback context. Cloning it retains that same context. Captures own their state and may outlive the plugin call that receives it.

Source

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.

Source

pub fn as_ref(&self) -> CallbackRef<'_>

Source

pub fn call(&mut self, input: &[u8], output: &mut [u8]) -> Result<usize>

Source

pub fn try_clone(&self) -> Result<Self>

Source

pub fn into_raw(self) -> RawCallback

Transfer one retained reference, to be released exactly once.

Trait Implementations§

Source§

impl Drop for Callback

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.