pub struct VMHostFunctions<'a> { /* private fields */ }Expand description
The self-referencing struct.
Implementations§
Source§impl VMHostFunctions<'_>
impl VMHostFunctions<'_>
pub fn panic(&mut self, location_ptr: u64) -> VMLogicResult<()>
pub fn panic_utf8( &mut self, msg_ptr: u64, location_ptr: u64, ) -> VMLogicResult<()>
pub fn register_len(&self, register_id: u64) -> VMLogicResult<u64>
pub fn read_register( &self, register_id: u64, register_ptr: u64, ) -> VMLogicResult<u32>
pub fn context_id(&mut self, register_id: u64) -> VMLogicResult<()>
pub fn executor_id(&mut self, register_id: u64) -> VMLogicResult<()>
pub fn input(&mut self, register_id: u64) -> VMLogicResult<()>
pub fn value_return(&mut self, value_ptr: u64) -> VMLogicResult<()>
pub fn log_utf8(&mut self, log_ptr: u64) -> VMLogicResult<()>
pub fn emit(&mut self, event_ptr: u64) -> VMLogicResult<()>
pub fn commit( &mut self, root_hash_ptr: u64, artifact_ptr: u64, ) -> VMLogicResult<()>
pub fn storage_read( &mut self, key_ptr: u64, register_id: u64, ) -> VMLogicResult<u32>
pub fn storage_remove( &mut self, key_ptr: u64, register_id: u64, ) -> VMLogicResult<u32>
pub fn storage_write( &mut self, key_ptr: u64, value_ptr: u64, register_id: u64, ) -> VMLogicResult<u32>
pub fn fetch( &mut self, url_ptr: u64, method_ptr: u64, headers_ptr: u64, body_ptr: u64, register_id: u64, ) -> VMLogicResult<u32>
pub fn random_bytes(&mut self, ptr: u64) -> VMLogicResult<()>
Sourcepub fn time_now(&mut self, ptr: u64) -> VMLogicResult<()>
pub fn time_now(&mut self, ptr: u64) -> VMLogicResult<()>
Gets the current time.
This function obtains the current time as a nanosecond timestamp, as
SystemTime is not available inside the guest runtime. Therefore the
guest needs to request this from the host.
Sourcepub fn send_proposal(
&mut self,
actions_ptr: u64,
id_ptr: u64,
) -> VMLogicResult<()>
pub fn send_proposal( &mut self, actions_ptr: u64, id_ptr: u64, ) -> VMLogicResult<()>
Call the contract’s send_proposal() function through the bridge.
The proposal actions are obtained as raw data and pushed onto a list of proposals to be sent to the host.
Note that multiple actions are received, and the entire batch is pushed onto the proposal list to represent one proposal.
§Parameters
actions_ptr- Pointer to the start of the action data in WASM memory.actions_len- Length of the action data.id_ptr- Pointer to the start of the id data in WASM memory.id_len- Length of the action data. This should be 32 bytes.
pub fn approve_proposal(&mut self, approval_ptr: u64) -> VMLogicResult<()>
Sourcepub fn blob_create(&mut self) -> VMLogicResult<u64>
pub fn blob_create(&mut self) -> VMLogicResult<u64>
Create a new blob for writing Returns: file descriptor (u64) for writing operations
Sourcepub fn blob_write(&mut self, fd: u64, data_ptr: u64) -> VMLogicResult<u64>
pub fn blob_write(&mut self, fd: u64, data_ptr: u64) -> VMLogicResult<u64>
Write a chunk of data to a blob Returns: number of bytes written (u64)
Sourcepub fn blob_close(&mut self, fd: u64, blob_id_ptr: u64) -> VMLogicResult<u32>
pub fn blob_close(&mut self, fd: u64, blob_id_ptr: u64) -> VMLogicResult<u32>
Close a blob handle and get the resulting blob ID Returns: 1 on success
Sourcepub fn blob_announce_to_context(
&mut self,
blob_id_ptr: u64,
context_id_ptr: u64,
) -> VMLogicResult<u32>
pub fn blob_announce_to_context( &mut self, blob_id_ptr: u64, context_id_ptr: u64, ) -> VMLogicResult<u32>
Announce a blob to a specific context for network discovery
Sourcepub fn blob_open(&mut self, blob_id_ptr: u64) -> VMLogicResult<u64>
pub fn blob_open(&mut self, blob_id_ptr: u64) -> VMLogicResult<u64>
Open a blob for reading Returns: file descriptor (u64) for reading operations
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for VMHostFunctions<'a>
impl<'a> !RefUnwindSafe for VMHostFunctions<'a>
impl<'a> !Send for VMHostFunctions<'a>
impl<'a> !Sync for VMHostFunctions<'a>
impl<'a> Unpin for VMHostFunctions<'a>
impl<'a> !UnwindSafe for VMHostFunctions<'a>
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Constraint for T
impl<T> Constraint for T
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more