pub trait OcallFuncs {
Show 28 methods // Required methods fn close(&mut self, resource_id: i32) -> Result<()>; fn poll(&mut self, waker_id: i32, resource_id: i32) -> Result<Vec<u8>>; fn poll_read( &mut self, waker_id: i32, resource_id: i32, data: &mut [u8] ) -> Result<u32>; fn poll_write( &mut self, waker_id: i32, resource_id: i32, data: &[u8] ) -> Result<u32>; fn poll_shutdown(&mut self, waker_id: i32, resource_id: i32) -> Result<()>; fn poll_res(&mut self, waker_id: i32, resource_id: i32) -> Result<i32>; fn mark_task_ready(&mut self, task_id: i32) -> Result<()>; fn next_ready_task(&mut self) -> Result<i32>; fn enable_ocall_trace(&mut self, enable: bool) -> Result<()>; fn awake_wakers(&mut self) -> Result<Vec<i32>>; fn getrandom(&mut self, buf: &mut [u8]) -> Result<()>; fn create_timer(&mut self, timeout: i32) -> Result<i32>; fn oneshot_send(&mut self, resource_id: i32, data: &[u8]) -> Result<()>; fn gas_remaining(&mut self) -> Result<u8>; fn tcp_listen( &mut self, addr: Cow<'_, str>, tls_config: Option<TlsServerConfig> ) -> Result<i32>; fn tcp_accept( &mut self, waker_id: i32, resource_id: i32 ) -> Result<(i32, String)>; fn tcp_accept_no_addr( &mut self, waker_id: i32, resource_id: i32 ) -> Result<i32>; fn tcp_connect(&mut self, host: &str, port: u16) -> Result<i32>; fn tcp_connect_tls( &mut self, host: String, port: u16, config: TlsClientConfig ) -> Result<i32>; fn log(&mut self, level: Level, message: &str) -> Result<()>; fn local_cache_get(&mut self, key: &[u8]) -> Result<Option<Vec<u8>>>; fn local_cache_set(&mut self, key: &[u8], value: &[u8]) -> Result<()>; fn local_cache_set_expiration( &mut self, key: &[u8], expire_after_secs: u64 ) -> Result<()>; fn local_cache_remove(&mut self, key: &[u8]) -> Result<Option<Vec<u8>>>; fn create_input_channel(&mut self, ch: InputChannel) -> Result<i32>; fn query_local_contract( &mut self, contract_id: [u8; 32], payload: Vec<u8> ) -> Result<i32>; fn vmid(&mut self) -> Result<[u8; 32]>; fn emit_program_output(&mut self, output: &[u8]) -> Result<()>;
}
Expand description

All ocall definitions for pink Sidevm.

Required Methods§

source

fn close(&mut self, resource_id: i32) -> Result<()>

Close given resource by id.

source

fn poll(&mut self, waker_id: i32, resource_id: i32) -> Result<Vec<u8>>

Poll given resource by id and return a dynamic sized data.

source

fn poll_read( &mut self, waker_id: i32, resource_id: i32, data: &mut [u8] ) -> Result<u32>

Poll given resource to read data. Low level support for AsyncRead.

source

fn poll_write( &mut self, waker_id: i32, resource_id: i32, data: &[u8] ) -> Result<u32>

Poll given resource to write data. Low level support for AsyncWrite.

source

fn poll_shutdown(&mut self, waker_id: i32, resource_id: i32) -> Result<()>

Shutdown a socket

source

fn poll_res(&mut self, waker_id: i32, resource_id: i32) -> Result<i32>

Poll given resource to generate a new resource id.

source

fn mark_task_ready(&mut self, task_id: i32) -> Result<()>

Mark a task as ready for next polling

source

fn next_ready_task(&mut self) -> Result<i32>

Get the next waken up task id.

source

fn enable_ocall_trace(&mut self, enable: bool) -> Result<()>

Enable logging for ocalls

source

fn awake_wakers(&mut self) -> Result<Vec<i32>>

Get awake wakers

source

fn getrandom(&mut self, buf: &mut [u8]) -> Result<()>

Get random number

source

fn create_timer(&mut self, timeout: i32) -> Result<i32>

Create a timer given a duration of time in milliseconds.

source

fn oneshot_send(&mut self, resource_id: i32, data: &[u8]) -> Result<()>

Send data to a oneshot channel.

source

fn gas_remaining(&mut self) -> Result<u8>

Percentage of the gas remaining to the next breath

source

fn tcp_listen( &mut self, addr: Cow<'_, str>, tls_config: Option<TlsServerConfig> ) -> Result<i32>

Create a TCP socket, bind to given address and listen to incoming connections.

If tls_config is not None, then the socket will be TLS encrypted. Invoke tcp_accept on the returned resource_id to accept incoming connections.

source

fn tcp_accept( &mut self, waker_id: i32, resource_id: i32 ) -> Result<(i32, String)>

Accept incoming TCP connections.

source

fn tcp_accept_no_addr(&mut self, waker_id: i32, resource_id: i32) -> Result<i32>

Accept incoming TCP connections without returning the remote address.

source

fn tcp_connect(&mut self, host: &str, port: u16) -> Result<i32>

Initiate a TCP connection to a remote endpoint.

source

fn tcp_connect_tls( &mut self, host: String, port: u16, config: TlsClientConfig ) -> Result<i32>

Initiate a TLS/TCP connection to a remote endpoint.

source

fn log(&mut self, level: Level, message: &str) -> Result<()>

Print log message.

source

fn local_cache_get(&mut self, key: &[u8]) -> Result<Option<Vec<u8>>>

Get value from the local cache.

source

fn local_cache_set(&mut self, key: &[u8], value: &[u8]) -> Result<()>

Set value to the local cache.

source

fn local_cache_set_expiration( &mut self, key: &[u8], expire_after_secs: u64 ) -> Result<()>

Set expiration time for a key in the local cache.

source

fn local_cache_remove(&mut self, key: &[u8]) -> Result<Option<Vec<u8>>>

Remove a value from the local cache.

Returns the previous value if it existed.

source

fn create_input_channel(&mut self, ch: InputChannel) -> Result<i32>

Create input channel

source

fn query_local_contract( &mut self, contract_id: [u8; 32], payload: Vec<u8> ) -> Result<i32>

Query a local contract within the same worker

Returns a channel id for the query result.

Limitation

Only one query can be processed at a time.

source

fn vmid(&mut self) -> Result<[u8; 32]>

Returns the vmid of the current instance.

source

fn emit_program_output(&mut self, output: &[u8]) -> Result<()>

Emit program output.

Implementors§