Skip to main content

CallbackInterface

Trait CallbackInterface 

Source
pub trait CallbackInterface {
    type Vtable: Vtable;

    // Required method
    fn from_foreign(cb: ForeignCallback<Self::Vtable>) -> Arc<Self> ⓘ;
}
Expand description

Ties a callback interface’s dyn Trait to its generated vtable and foreign wrapper.

The #[weaveffi::module] expansion implements this for dyn Trait of every #[weaveffi::callback_interface], which lets a thunk that only knows the producer’s written type (Arc<dyn Trait>) name the vtable slot type (<dyn Trait as CallbackInterface>::Vtable) and lift the pair into a shared trait object with lift_callback.

Required Associated Types§

Source

type Vtable: Vtable

The generated #[repr(C)] vtable struct for this interface.

Required Methods§

Source

fn from_foreign(cb: ForeignCallback<Self::Vtable>) -> Arc<Self> ⓘ

Wrap a lifted foreign callback as a shared trait object.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§