marine_module_interface/it_interface/
it_module_interface.rs

1/*
2 * Copyright 2021 Fluence Labs Limited
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17use wasmer_it::IType;
18use wasmer_it::ast::FunctionArg as IFunctionArg;
19use wasmer_it::IRecordType;
20
21use serde::Serialize;
22use serde::Deserialize;
23
24use std::collections::HashMap;
25use std::sync::Arc;
26
27pub type IRecordTypes = HashMap<u64, Arc<IRecordType>>;
28
29/// Represent a function type inside Marine module.
30#[derive(PartialEq, Eq, Debug, Clone, Hash, Serialize, Deserialize)]
31pub struct IFunctionSignature {
32    pub name: Arc<String>,
33    pub arguments: Arc<Vec<IFunctionArg>>,
34    pub outputs: Arc<Vec<IType>>,
35    pub adapter_function_type: u32,
36}
37
38/// Represent an interface of a Wasm module.
39#[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)]
40pub struct IModuleInterface {
41    pub export_record_types: IRecordTypes,
42    pub record_types: IRecordTypes,
43    pub function_signatures: Vec<IFunctionSignature>,
44}