pub trait NativeAPI {
Show 16 methods
// Required methods
fn exit(&self, exit_code: ExitCode) -> !;
fn state(&self) -> u32;
fn read(&self, target: &mut [u8], offset: u32);
fn input_size(&self) -> u32;
fn write(&self, value: &[u8]);
fn output_size(&self) -> u32;
fn read_output(&self, target: &mut [u8], offset: u32);
fn exec(
&self,
code_hash: BytecodeOrHash,
input: Cow<'_, [u8]>,
fuel_limit: Option<u64>,
state: u32,
) -> (u64, i64, i32);
fn resume(
&self,
call_id: u32,
return_data: &[u8],
exit_code: i32,
fuel_consumed: u64,
fuel_refunded: i64,
) -> (u64, i64, i32);
fn forward_output(&self, offset: u32, len: u32);
fn fuel(&self) -> u64;
fn debug_log(message: &str);
fn charge_fuel(&self, fuel_consumed: u64);
fn enter_unconstrained(&self);
fn exit_unconstrained(&self);
fn write_fd(&self, fd: u32, slice: &[u8]);
}Expand description
A trait for providing shared API functionality.
Required Methods§
Sourcefn exit(&self, exit_code: ExitCode) -> !
fn exit(&self, exit_code: ExitCode) -> !
Low-level function that terminates the execution of the program and exits with the specified exit code.
fn state(&self) -> u32
fn read(&self, target: &mut [u8], offset: u32)
Sourcefn input_size(&self) -> u32
fn input_size(&self) -> u32
Returns the size of the input data provided to the runtime environment.
fn write(&self, value: &[u8])
fn output_size(&self) -> u32
fn read_output(&self, target: &mut [u8], offset: u32)
Sourcefn exec(
&self,
code_hash: BytecodeOrHash,
input: Cow<'_, [u8]>,
fuel_limit: Option<u64>,
state: u32,
) -> (u64, i64, i32)
fn exec( &self, code_hash: BytecodeOrHash, input: Cow<'_, [u8]>, fuel_limit: Option<u64>, state: u32, ) -> (u64, i64, i32)
Executes a nested call with specified bytecode poseidon hash.
Sourcefn resume(
&self,
call_id: u32,
return_data: &[u8],
exit_code: i32,
fuel_consumed: u64,
fuel_refunded: i64,
) -> (u64, i64, i32)
fn resume( &self, call_id: u32, return_data: &[u8], exit_code: i32, fuel_consumed: u64, fuel_refunded: i64, ) -> (u64, i64, i32)
Resumes the execution of a previously suspended function call.
fn forward_output(&self, offset: u32, len: u32)
fn fuel(&self) -> u64
fn debug_log(message: &str)
Sourcefn charge_fuel(&self, fuel_consumed: u64)
fn charge_fuel(&self, fuel_consumed: u64)
Charges specified amount of fuel.
In contrast to _charge_fuel_manually, can be called from untrusted code since it can only
charge fuel.
fn enter_unconstrained(&self)
fn exit_unconstrained(&self)
fn write_fd(&self, fd: u32, slice: &[u8])
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.