fluence_it_types/values.rs
1//! Defines WIT values and associated operations.
2
3use crate::ne_vec::NEVec;
4
5use variant_count::VariantCount;
6
7/// A WIT value.
8#[derive(Debug, Clone, PartialEq, VariantCount)]
9pub enum IValue {
10 /// Boolean value.
11 Boolean(bool),
12
13 /// A 8-bits signed integer.
14 S8(i8),
15
16 /// A 16-bits signed integer.
17 S16(i16),
18
19 /// A 32-bits signed integer.
20 S32(i32),
21
22 /// A 64-bits signed integer.
23 S64(i64),
24
25 /// A 8-bits unsigned integer.
26 U8(u8),
27
28 /// A 16-bits unsigned integer.
29 U16(u16),
30
31 /// A 32-bits unsigned integer.
32 U32(u32),
33
34 /// A 64-bits unsigned integer.
35 U64(u64),
36
37 /// A 32-bits float.
38 F32(f32),
39
40 /// A 64-bits float.
41 F64(f64),
42
43 /// A string.
44 String(String),
45
46 /// Specialization of array type for byte vector.
47 ByteArray(Vec<u8>),
48
49 /// A byte array.
50 Array(Vec<IValue>),
51
52 /// A 32-bits integer (as defined in WebAssembly core).
53 I32(i32),
54
55 /// A 64-bits integer (as defined in WebAssembly core).
56 I64(i64),
57
58 /// A record.
59 Record(NEVec<IValue>),
60}
61
62impl Default for IValue {
63 fn default() -> Self {
64 Self::I32(0)
65 }
66}