marine/
lib.rs

1/*
2 * Copyright 2020 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#![warn(rust_2018_idioms)]
17#![deny(
18    dead_code,
19    nonstandard_style,
20    unused_imports,
21    unused_mut,
22    unused_variables,
23    unused_unsafe,
24    unreachable_patterns
25)]
26
27mod config;
28mod host_imports;
29mod errors;
30mod marine;
31mod marine_interface;
32mod module_loading;
33
34pub(crate) type MarineResult<T> = std::result::Result<T, MarineError>;
35
36pub use marine_interface::MarineInterface;
37
38pub use config::ConfigContext;
39pub use config::WithContext;
40pub use config::MarineWASIConfig;
41
42pub use config::TomlMarineConfig;
43pub use config::TomlMarineModuleConfig;
44pub use config::TomlMarineNamedModuleConfig;
45pub use config::TomlWASIConfig;
46pub use config::TomlValue;
47pub use config::TomlValueTable;
48
49pub use errors::MarineError;
50
51// Re-exports from Marine
52pub use marine_core::IValue;
53pub use marine_core::IRecordType;
54pub use marine_core::IFunctionArg;
55pub use marine_core::IType;
56pub use marine_core::MModuleInterface as MarineModuleInterface;
57pub use marine_core::MError;
58pub use marine_core::MFunctionSignature as MarineFunctionSignature;
59pub use marine_core::MemoryStats;
60pub use marine_core::ModuleMemoryStat;
61pub use marine_core::MRecordTypes;
62pub use marine_core::HostImportError;
63pub use marine_core::to_interface_value;
64pub use marine_core::from_interface_values;
65pub use marine_core::ne_vec;
66
67pub use marine_module_interface::interface::itype_text_view;
68
69pub use marine_rs_sdk::CallParameters;
70pub use marine_rs_sdk::ParticleParameters;
71pub use marine_rs_sdk::SecurityTetraplet;
72
73pub mod generic {
74    pub use crate::marine::Marine;
75    pub use crate::config::MarineModuleConfig;
76    pub use crate::config::ModuleDescriptor;
77    pub use crate::config::MarineConfig;
78
79    pub use marine_core::generic::*;
80}
81
82#[cfg(feature = "default")]
83pub mod wasmtime {
84    pub type WasmBackend = marine_core::wasmtime::WasmBackend;
85
86    pub type Marine = crate::marine::Marine<WasmBackend>;
87    pub type MarineModuleConfig = crate::config::MarineModuleConfig<WasmBackend>;
88    pub type ModuleDescriptor = crate::config::ModuleDescriptor<WasmBackend>;
89    pub type MarineConfig = crate::config::MarineConfig<WasmBackend>;
90
91    pub use marine_core::wasmtime::HostExportedFunc;
92    pub use marine_core::wasmtime::HostImportDescriptor;
93}
94
95#[cfg(feature = "default")]
96pub use wasmtime::*;