marine_module_interface/it_interface/mod.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
17mod errors;
18mod export_it_functions;
19mod export_it_records;
20mod it_module_interface;
21
22pub use errors::*;
23pub use export_it_functions::*;
24pub use export_it_records::*;
25pub use it_module_interface::*;
26
27pub type RIResult<T> = std::result::Result<T, ITInterfaceError>;
28
29use marine_it_interfaces::MITInterfaces;
30
31/// Returns Marine module interface that includes both export and all record types.
32pub fn get_interface(mit: &MITInterfaces<'_>) -> RIResult<IModuleInterface> {
33 let function_signatures = get_export_funcs(mit)?;
34 let FullRecordTypes {
35 record_types,
36 export_record_types,
37 } = get_record_types(mit, function_signatures.iter())?;
38
39 let mm_interface = IModuleInterface {
40 export_record_types,
41 record_types,
42 function_signatures,
43 };
44
45 Ok(mm_interface)
46}