VMHostFunctions

Struct VMHostFunctions 

Source
pub struct VMHostFunctions<'a> { /* private fields */ }
Expand description

The self-referencing struct.

Implementations§

Source§

impl VMHostFunctions<'_>

Source

pub fn panic(&mut self, location_ptr: u64) -> VMLogicResult<()>

Source

pub fn panic_utf8( &mut self, msg_ptr: u64, location_ptr: u64, ) -> VMLogicResult<()>

Source

pub fn register_len(&self, register_id: u64) -> VMLogicResult<u64>

Source

pub fn read_register( &self, register_id: u64, register_ptr: u64, ) -> VMLogicResult<u32>

Source

pub fn context_id(&mut self, register_id: u64) -> VMLogicResult<()>

Source

pub fn executor_id(&mut self, register_id: u64) -> VMLogicResult<()>

Source

pub fn input(&mut self, register_id: u64) -> VMLogicResult<()>

Source

pub fn value_return(&mut self, value_ptr: u64) -> VMLogicResult<()>

Source

pub fn log_utf8(&mut self, log_ptr: u64) -> VMLogicResult<()>

Source

pub fn emit(&mut self, event_ptr: u64) -> VMLogicResult<()>

Source

pub fn commit( &mut self, root_hash_ptr: u64, artifact_ptr: u64, ) -> VMLogicResult<()>

Source

pub fn storage_read( &mut self, key_ptr: u64, register_id: u64, ) -> VMLogicResult<u32>

Source

pub fn storage_remove( &mut self, key_ptr: u64, register_id: u64, ) -> VMLogicResult<u32>

Source

pub fn storage_write( &mut self, key_ptr: u64, value_ptr: u64, register_id: u64, ) -> VMLogicResult<u32>

Source

pub fn fetch( &mut self, url_ptr: u64, method_ptr: u64, headers_ptr: u64, body_ptr: u64, register_id: u64, ) -> VMLogicResult<u32>

Source

pub fn random_bytes(&mut self, ptr: u64) -> VMLogicResult<()>

Source

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.

Source

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.
Source

pub fn approve_proposal(&mut self, approval_ptr: u64) -> VMLogicResult<()>

Source

pub fn blob_create(&mut self) -> VMLogicResult<u64>

Create a new blob for writing Returns: file descriptor (u64) for writing operations

Source

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)

Source

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

Source

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

Source

pub fn blob_open(&mut self, blob_id_ptr: u64) -> VMLogicResult<u64>

Open a blob for reading Returns: file descriptor (u64) for reading operations

Source

pub fn blob_read(&mut self, fd: u64, data_ptr: u64) -> VMLogicResult<u64>

Read a chunk of data from a blob Returns: number of bytes read (u64)

Trait Implementations§

Source§

impl<'a> Drop for VMHostFunctions<'a>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Constraint for T

Source§

fn validate<R>(self) -> Result<Constrained<T, R>, <R as Constrains<T>>::Error>
where R: Constrains<T>,

Source§

impl<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

Source§

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Gets the layout of the type.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The type for metadata in pointers and references to Self.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Reflect for T

Source§

fn as_dyn_ref<'a>(&self) -> &(dyn Reflect + 'a)
where T: 'a,

Source§

fn as_dyn_mut<'a>(&mut self) -> &mut (dyn Reflect + 'a)
where T: 'a,

Source§

fn as_dyn_box<'a>(self: Box<T>) -> Box<dyn Reflect + 'a>
where T: 'a,

Source§

fn as_dyn_rc<'a>(self: Rc<T>) -> Rc<dyn Reflect + 'a>
where T: 'a,

Source§

fn as_dyn_arc<'a>(self: Arc<T>) -> Arc<dyn Reflect + 'a>
where T: 'a,

Source§

fn type_id(&self) -> TypeId

Source§

fn type_name(&self) -> &'static str

Source§

impl<T> ReflectExt for T
where T: Reflect + ?Sized,

Source§

fn is<T>(&self) -> bool
where T: Reflect + ?Sized,

Source§

fn type_id() -> TypeId

Source§

fn downcast_ref<T>(&self) -> Option<&T>
where T: Reflect,

Source§

fn downcast_mut<T>(&mut self) -> Option<&mut T>
where T: Reflect,

Source§

fn downcast_box<T>(self: Box<Self>) -> Result<Box<T>, Box<Self>>
where T: Reflect,

Source§

fn downcast_rc<T>(self: Rc<Self>) -> Result<Rc<T>, Rc<Self>>
where T: Reflect,

Source§

fn downcast_arc<T>(self: Arc<Self>) -> Result<Arc<T>, Arc<Self>>
where T: Reflect,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,