inkpad-derive

Crates.ioinkpad-derive
lib.rsinkpad-derive
version0.1.0
sourcesrc
created_at2022-01-29 08:32:43.827587
updated_at2022-01-29 08:32:43.827587
descriptionderive macros for inkpad
homepage
repositoryhttps://github.com/patractlabs/inkpad
max_upload_size
id523491
size18,840
(clearloop)

documentation

README

Inkpad Derive

crate doc downloads LICENSE

Procedural macros for inkpad

#[host(module)]

#[host(seal0)]
fn seal_input(out_ptr: u32, out_len_ptr: u32) -> Result<ReturnValue>;
struct SealInput;

impl Host for SealInput {
    fn module() -> &'static str {
        "seal0"
    }
    
    fn name() -> &'static str {
        "seal_input"
    }
    
    fn wrap() -> HostFuncType<Sandbox> {
        fn(sandbox: &mut Sandbox, args: &[Value]) -> Result<ReturnValue> {
            if args.len() != 2 {
                return Err(Error::WrongArugmentLength);
            }
            
            let [out_ptr, out_len_ptr] = [args[0].into(), args[1].into()];
            seal_input(sandbox, out_ptr, out_len_ptr)
        }
    }
    
    /// Pack instance
    fn pack() -> (&'static str, &'static str, HostFuncType<Sandbox>) {
        (
            <Self as Host>::module(),
            <Self as Host>::name(),
            <Self as Host>::wrap,
        )
    }
}

LICNESE

MIT

Commit count: 0

cargo fmt