Struct wasmtime::Global[][src]

pub struct Global { /* fields omitted */ }

A WebAssembly global value which can be read and written to.

A global in WebAssembly is sort of like a global variable within an Instance. The global.get and global.set instructions will modify and read global values in a wasm module. Globals can either be imported or exported from wasm modules.

If you’re familiar with Rust already you can think of a Global as a sort of Rc<Cell<Val>>, more or less.

Global and Clone

Globals are internally reference counted so you can clone a Global. The cloning process only performs a shallow clone, so two cloned Global instances are equivalent in their functionality.

Implementations

impl Global[src]

pub fn new(store: &Store, ty: GlobalType, val: Val) -> Result<Global>[src]

Creates a new WebAssembly global value with the provide type ty and initial value val.

The store argument provided is used as a general global cache for information, and otherwise the ty and val arguments are used to initialize the global.

Errors

Returns an error if the ty provided does not match the type of the value val.

pub fn ty(&self) -> GlobalType[src]

Returns the underlying type of this global.

pub fn val_type(&self) -> ValType[src]

Returns the value type of this global.

pub fn mutability(&self) -> Mutability[src]

Returns the underlying mutability of this global.

pub fn get(&self) -> Val[src]

Returns the current Val of this global.

pub fn set(&self, val: Val) -> Result<()>[src]

Attempts to set the current value of this global to Val.

Errors

Returns an error if this global has a different type than Val, or if it’s not a mutable global.

Trait Implementations

impl Clone for Global[src]

impl From<Global> for Extern[src]

Auto Trait Implementations

impl !RefUnwindSafe for Global

impl !Send for Global

impl !Sync for Global

impl Unpin for Global

impl !UnwindSafe for Global

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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