Wasmtime
wasmtime::component::Val Class Reference

Class representing an instantiated WebAssembly component. More...

#include <val.hh>

Public Member Functions

 Val (Raw &&capi)
 
 Val (const Val &other)
 Copy constructor to clone other.
More...
 
Valoperator= (const Val &other)
 Copy assignment to clone from other.
More...
 
 Val (Val &&other)
 Move constructor to move the contents of other.
More...
 
Valoperator= (Val &&other)
 Move assignment to move the contents of other.
More...
 
const Rawcapi () const
 Returns a pointer to the underlying C API representation.
More...
 
 Val (bool v)
 Creates a new boolean value.
 
 Val (uint8_t v)
 Creates a new u8 value.
 
 Val (int8_t v)
 Creates a new s8 value.
 
 Val (uint16_t v)
 Creates a new u16 value.
 
 Val (int16_t v)
 Creates a new s16 value.
 
 Val (uint32_t v)
 Creates a new u32 value.
 
 Val (int32_t v)
 Creates a new s32 value.
 
 Val (uint64_t v)
 Creates a new u64 value.
 
 Val (int64_t v)
 Creates a new s64 value.
 
 Val (float v)
 Creates a new f32 value.
 
 Val (double v)
 Creates a new f64 value.
 
 Val (List v)
 Creates a new list value.
 
 Val (Record r)
 Creates a new record value.
 
 Val (Tuple v)
 Creates a new tuple value.
 
 Val (Variant v)
 Creates a new variant value.
 
 Val (WitOption v)
 Creates a new option value.
 
 Val (WitResult r)
 Creates a new result value.
 
 Val (Flags f)
 Creates a new flags value.
 
 Val (ResourceAny r)
 Creates a new resource value.
 
bool is_bool () const
 Returns whether this value is a boolean.
 
bool get_bool () const
 Returns the boolean value, only valid if is_bool().
 
bool is_u8 () const
 Returns whether this value is a u8.
 
uint8_t get_u8 () const
 Returns the u8 value, only valid if is_u8().
 
bool is_s8 () const
 Returns whether this value is a s8.
 
int8_t get_s8 () const
 Returns the s8 value, only valid if is_s8().
 
bool is_u16 () const
 Returns whether this value is a u16.
 
uint16_t get_u16 () const
 Returns the u16 value, only valid if is_u16().
 
bool is_s16 () const
 Returns whether this value is a s16.
 
int16_t get_s16 () const
 Returns the s16 value, only valid if is_s16().
 
bool is_u32 () const
 Returns whether this value is a u32.
 
uint32_t get_u32 () const
 Returns the u32 value, only valid if is_u32().
 
bool is_s32 () const
 Returns whether this value is a s32.
 
int32_t get_s32 () const
 Returns the s32 value, only valid if is_s32().
 
bool is_u64 () const
 Returns whether this value is a u64.
 
uint64_t get_u64 () const
 Returns the u64 value, only valid if is_u64().
 
bool is_s64 () const
 Returns whether this value is a s64.
 
int64_t get_s64 () const
 Returns the s64 value, only valid if is_s64().
 
bool is_f32 () const
 Returns whether this value is a f32.
 
float get_f32 () const
 Returns the f32 value, only valid if is_f32().
 
bool is_f64 () const
 Returns whether this value is a f64.
 
double get_f64 () const
 Returns the f64 value, only valid if is_f64().
 
bool is_string () const
 Returns whether this value is a string.
 
std::string_view get_string () const
 Returns the string value, only valid if is_string().
 
bool is_list () const
 Returns whether this value is a list.
 
const Listget_list () const
 Returns the list value, only valid if is_list().
 
bool is_record () const
 Returns whether this value is a record.
 
const Recordget_record () const
 Returns the record value, only valid if is_record().
 
bool is_tuple () const
 Returns whether this value is a tuple.
 
const Tupleget_tuple () const
 Returns the tuple value, only valid if is_tuple().
 
bool is_variant () const
 Returns whether this value is a variant.
 
const Variantget_variant () const
 Returns the variant value, only valid if is_variant().
 
bool is_option () const
 Returns whether this value is an option.
 
const WitOptionget_option () const
 Returns the option value, only valid if is_option().
 
bool is_enum () const
 Returns whether this value is an enum.
 
std::string_view get_enum () const
 Returns the enum discriminant, only valid if is_enum().
 
bool is_result () const
 Returns whether this value is a result.
 
const WitResultget_result () const
 Returns the result value, only valid if is_result().
 
bool is_flags () const
 Returns whether this value is flags.
 
const Flagsget_flags () const
 Returns the flags value, only valid if is_flags().
 
bool is_resource () const
 Returns whether this value is a resource.
 
const ResourceAnyget_resource () const
 Returns the flags value, only valid if is_flags().
 

Static Public Member Functions

static const Valfrom_capi (const Raw *capi)
 
static Valfrom_capi (Raw *capi)
 
static const Rawto_capi (const Val *capi)
 
static Rawto_capi (Val *capi)
 
static Val char_ (uint32_t v)
 Creates a new char value.
 
static Val string (std::string_view v)
 Creates a new string value.
 
static Val enum_ (std::string_view discriminant)
 Creates a new enum value.
 

Friends

class Variant
 
class WitOption
 
class WitResult
 

Detailed Description

Class representing an instantiated WebAssembly component.

Constructor & Destructor Documentation

◆ Val() [1/3]

wasmtime::component::Val::Val ( Raw &&  capi)
inlineexplicit
  • Create a variant that takes ownership of the underlying C API variant.

◆ Val() [2/3]

wasmtime::component::Val::Val ( const Val other)
inline

Copy constructor to clone other.

◆ Val() [3/3]

wasmtime::component::Val::Val ( Val &&  other)
inline

Move constructor to move the contents of other.

Member Function Documentation

◆ capi()

const Raw * wasmtime::component::Val::capi ( ) const
inline

Returns a pointer to the underlying C API representation.

◆ from_capi() [1/2]

static const Val * wasmtime::component::Val::from_capi ( const Raw capi)
inlinestatic
  • Converts the raw C API representation to this class without taking * ownership.

◆ from_capi() [2/2]

static Val * wasmtime::component::Val::from_capi ( Raw capi)
inlinestatic
  • Converts the raw C API representation to this class without taking * ownership.

◆ operator=() [1/2]

Val & wasmtime::component::Val::operator= ( const Val other)
inline

Copy assignment to clone from other.

◆ operator=() [2/2]

Val & wasmtime::component::Val::operator= ( Val &&  other)
inline

Move assignment to move the contents of other.

◆ to_capi() [1/2]

static const Raw * wasmtime::component::Val::to_capi ( const Val capi)
inlinestatic
  • Converts to the raw C API representation to this class without taking * ownership.

◆ to_capi() [2/2]

static Raw * wasmtime::component::Val::to_capi ( Val capi)
inlinestatic
  • Converts to the raw C API representation to this class without taking * ownership.

The documentation for this class was generated from the following file: