Crates.io | ceres-derive |
lib.rs | ceres-derive |
version | 0.2.0 |
source | src |
created_at | 2021-06-14 07:07:30.607602 |
updated_at | 2021-08-02 09:42:43.475853 |
description | derive macros for ceres |
homepage | |
repository | https://github.com/patractlabs/ceres |
max_upload_size | |
id | 409825 |
size | 18,843 |
Procedural macros for ceres
#[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,
)
}
}
MIT