Trait ayaka_plugin::Linker

source ·
pub trait Linker<M: RawModule>: Sized {
    // Required methods
    fn new() -> 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 Methods§

source

fn new() -> 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.

Implementors§