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§
Sourcefn poll(&mut self, waker_id: i32, resource_id: i32) -> Result<Vec<u8>>
fn poll(&mut self, waker_id: i32, resource_id: i32) -> Result<Vec<u8>>
Poll given resource by id and return a dynamic sized data.
Sourcefn poll_read(
&mut self,
waker_id: i32,
resource_id: i32,
data: &mut [u8],
) -> Result<u32>
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.
Sourcefn poll_write(
&mut self,
waker_id: i32,
resource_id: i32,
data: &[u8],
) -> Result<u32>
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.
Sourcefn poll_res(&mut self, waker_id: i32, resource_id: i32) -> Result<i32>
fn poll_res(&mut self, waker_id: i32, resource_id: i32) -> Result<i32>
Poll given resource to generate a new resource id.
Sourcefn mark_task_ready(&mut self, task_id: i32) -> Result<()>
fn mark_task_ready(&mut self, task_id: i32) -> Result<()>
Mark a task as ready for next polling
Sourcefn next_ready_task(&mut self) -> Result<i32>
fn next_ready_task(&mut self) -> Result<i32>
Get the next waken up task id.
Sourcefn enable_ocall_trace(&mut self, enable: bool) -> Result<()>
fn enable_ocall_trace(&mut self, enable: bool) -> Result<()>
Enable logging for ocalls
Sourcefn awake_wakers(&mut self) -> Result<Vec<i32>>
fn awake_wakers(&mut self) -> Result<Vec<i32>>
Get awake wakers
Sourcefn create_timer(&mut self, timeout: i32) -> Result<i32>
fn create_timer(&mut self, timeout: i32) -> Result<i32>
Create a timer given a duration of time in milliseconds.
Sourcefn oneshot_send(&mut self, resource_id: i32, data: &[u8]) -> Result<()>
fn oneshot_send(&mut self, resource_id: i32, data: &[u8]) -> Result<()>
Send data to a oneshot channel.
Sourcefn gas_remaining(&mut self) -> Result<u8>
fn gas_remaining(&mut self) -> Result<u8>
Percentage of the gas remaining to the next breath
Sourcefn tcp_listen(
&mut self,
addr: Cow<'_, str>,
tls_config: Option<TlsServerConfig>,
) -> Result<i32>
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.
Sourcefn tcp_accept(
&mut self,
waker_id: i32,
resource_id: i32,
) -> Result<(i32, String)>
fn tcp_accept( &mut self, waker_id: i32, resource_id: i32, ) -> Result<(i32, String)>
Accept incoming TCP connections.
Sourcefn tcp_accept_no_addr(&mut self, waker_id: i32, resource_id: i32) -> Result<i32>
fn tcp_accept_no_addr(&mut self, waker_id: i32, resource_id: i32) -> Result<i32>
Accept incoming TCP connections without returning the remote address.
Sourcefn tcp_connect(&mut self, host: &str, port: u16) -> Result<i32>
fn tcp_connect(&mut self, host: &str, port: u16) -> Result<i32>
Initiate a TCP connection to a remote endpoint.
Sourcefn tcp_connect_tls(
&mut self,
host: String,
port: u16,
config: TlsClientConfig,
) -> Result<i32>
fn tcp_connect_tls( &mut self, host: String, port: u16, config: TlsClientConfig, ) -> Result<i32>
Initiate a TLS/TCP connection to a remote endpoint.
Sourcefn local_cache_get(&mut self, key: &[u8]) -> Result<Option<Vec<u8>>>
fn local_cache_get(&mut self, key: &[u8]) -> Result<Option<Vec<u8>>>
Get value from the local cache.
Sourcefn local_cache_set(&mut self, key: &[u8], value: &[u8]) -> Result<()>
fn local_cache_set(&mut self, key: &[u8], value: &[u8]) -> Result<()>
Set value to the local cache.
Sourcefn local_cache_set_expiration(
&mut self,
key: &[u8],
expire_after_secs: u64,
) -> Result<()>
fn local_cache_set_expiration( &mut self, key: &[u8], expire_after_secs: u64, ) -> Result<()>
Set expiration time for a key in the local cache.
Sourcefn local_cache_remove(&mut self, key: &[u8]) -> Result<Option<Vec<u8>>>
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.
Sourcefn create_input_channel(&mut self, ch: InputChannel) -> Result<i32>
fn create_input_channel(&mut self, ch: InputChannel) -> Result<i32>
Create input channel