mirror of
https://github.com/fluencelabs/interface-types
synced 2025-06-26 13:11:41 +00:00
feat(interface-types) Introduce RecordType
for InterfaceType
and Type
.
The `Type::Record` variant now is defined by `RecordType`. In addition, `InterfaceType` has a new variant: `Record`, that is also defined by `RecordType`. Encoders and decoders are updated to consider `RecordType`, which removes code duplication and simplify code.
This commit is contained in:
15
src/ast.rs
15
src/ast.rs
@ -48,6 +48,16 @@ pub enum InterfaceType {
|
||||
|
||||
/// A 64-bits integer (as defiend in WebAssembly core).
|
||||
I64,
|
||||
|
||||
/// A record.
|
||||
Record(RecordType),
|
||||
}
|
||||
|
||||
/// Representing a record type.
|
||||
#[derive(PartialEq, Debug, Clone)]
|
||||
pub struct RecordType {
|
||||
/// Types representing the fields.
|
||||
pub fields: Vec<InterfaceType>,
|
||||
}
|
||||
|
||||
/// Represents the kind of type.
|
||||
@ -81,10 +91,7 @@ pub enum Type {
|
||||
/// ```wasm,ignore
|
||||
/// (@interface type (record string i32))
|
||||
/// ```
|
||||
Record {
|
||||
/// Types representing the fields.
|
||||
fields: Vec<InterfaceType>,
|
||||
},
|
||||
Record(RecordType),
|
||||
}
|
||||
|
||||
/// Represents an imported function.
|
||||
|
Reference in New Issue
Block a user