Skip to main content

DiplomatCallback

Struct DiplomatCallback 

Source
#[repr(C)]
pub struct DiplomatCallback<ReturnType> { pub data: *mut c_void, pub run_callback: unsafe extern "C" fn(*mut c_void, ...) -> ReturnType, pub destructor: Option<unsafe extern "C" fn(*mut c_void)>, }
Expand description

Struct representing a callback from Rust into a foreign language

This is largely used internally by the Diplomat macro, and should not need to be constructed manually outside of that context

Fields§

§data: *mut c_void

Any data required to run the callback; e.g. a pointer to the callback wrapper object in the foreign runtime + the runtime itself

§run_callback: unsafe extern "C" fn(*mut c_void, ...) -> ReturnType

Function to actually run the callback. Note the first param is mutable, but depending on if this is passed to a Fn or FnMut may not actually need to be. FFI-Callers of said functions should cast to mutable.

Takes in self.data and any number of additional arguments.

§destructor: Option<unsafe extern "C" fn(*mut c_void)>

Function to destroy this callback struct.

Takes in self.data

Trait Implementations§

Source§

impl<ReturnType> Drop for DiplomatCallback<ReturnType>

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§

§

impl<ReturnType> Freeze for DiplomatCallback<ReturnType>

§

impl<ReturnType> RefUnwindSafe for DiplomatCallback<ReturnType>

§

impl<ReturnType> !Send for DiplomatCallback<ReturnType>

§

impl<ReturnType> !Sync for DiplomatCallback<ReturnType>

§

impl<ReturnType> Unpin for DiplomatCallback<ReturnType>

§

impl<ReturnType> UnsafeUnpin for DiplomatCallback<ReturnType>

§

impl<ReturnType> UnwindSafe for DiplomatCallback<ReturnType>

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.