Linker

Trait Linker 

Source
pub trait Linker<M: RawModule>: Sized {
    type Config;

    // Required methods
    fn new(config: Self::Config) -> Result<Self>;
    fn create(&self, binary: &[u8]) -> Result<M>;
    fn import(
        &mut self,
        ns: impl Into<String>,
        funcs: HashMap<String, M::Func>,
    ) -> Result<()>;
    fn wrap_raw(
        &self,
        f: impl Fn(M::LinkerHandle<'_>, i32, i32) -> Result<Vec<u8>> + Send + Sync + 'static,
    ) -> M::Func;

    // Provided methods
    fn wrap<P: DeserializeOwned + Tuple, R: Serialize>(
        &self,
        f: impl Fn(P) -> Result<R> + Send + Sync + 'static,
    ) -> M::Func { ... }
    fn wrap_with<P: DeserializeOwned + Tuple, R: Serialize>(
        &self,
        f: impl Fn(M::LinkerHandle<'_>, P) -> Result<R> + Send + Sync + 'static,
    ) -> M::Func { ... }
}
Expand description

Represents the linker of plugin modules.

Required Associated Types§

Source

type Config

Config type to create the linker.

Required Methods§

Source

fn new(config: Self::Config) -> Result<Self>

Create the linker.

Source

fn create(&self, binary: &[u8]) -> Result<M>

Create a raw module from binary.

Source

fn import( &mut self, ns: impl Into<String>, funcs: HashMap<String, M::Func>, ) -> Result<()>

Import functions by namespace and names.

Source

fn wrap_raw( &self, f: impl Fn(M::LinkerHandle<'_>, i32, i32) -> Result<Vec<u8>> + Send + Sync + 'static, ) -> M::Func

Wrap a function with args in bytes.

Provided Methods§

Source

fn wrap<P: DeserializeOwned + Tuple, R: Serialize>( &self, f: impl Fn(P) -> Result<R> + Send + Sync + 'static, ) -> M::Func

Wrap a function with args.

Source

fn wrap_with<P: DeserializeOwned + Tuple, R: Serialize>( &self, f: impl Fn(M::LinkerHandle<'_>, P) -> Result<R> + Send + Sync + 'static, ) -> M::Func

Wrap a function with args and linker handle.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§