Trait OcallFuncs

Source
pub trait OcallFuncs {
Show 25 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>;
}
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

Implementors§