Skip to main content

BuiltinFunctionDefinition

Trait BuiltinFunctionDefinition 

Source
pub trait BuiltinFunctionDefinition<C>
where C: ContextObject,
{ type Error: Into<Box<dyn Error>>; // Required method fn rust( vm: &mut C, arg_a: u64, arg_b: u64, arg_c: u64, arg_d: u64, arg_e: u64, ) -> Result<u64, Self::Error>; // Provided methods fn vm( vm: EncryptedHostAddressToEbpfVm<C>, a: u64, b: u64, c: u64, d: u64, e: u64, ) { ... } fn codegen(jit: &mut JitCompiler<'_, C>) { ... } fn register( program: &mut BuiltinProgram<C>, name: &str, ) -> Result<(), ElfError> where Self: Sized { ... } }
Expand description

Native built-in functions that can be made available to programs to call.

Required Associated Types§

Source

type Error: Into<Box<dyn Error>>

Error type returned by this built-in function.

Required Methods§

Source

fn rust( vm: &mut C, arg_a: u64, arg_b: u64, arg_c: u64, arg_d: u64, arg_e: u64, ) -> Result<u64, Self::Error>

The Rust side of the function logic.

This is the only method you are required to override.

Provided Methods§

Source

fn vm( vm: EncryptedHostAddressToEbpfVm<C>, a: u64, b: u64, c: u64, d: u64, e: u64, )

The VM wrapper.

Source

fn codegen(jit: &mut JitCompiler<'_, C>)

Hook for the JIT compiler on how to codegen this built-in function.

You could opt to codegen it in-line, but do note that defining the other methods is still required for non-JIT execution modes.

Source

fn register(program: &mut BuiltinProgram<C>, name: &str) -> Result<(), ElfError>
where Self: Sized,

Register this syscall to the provided program.

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§