mirror of
https://github.com/fluencelabs/marine.git
synced 2024-12-04 19:50:19 +00:00
add rustfmt config
This commit is contained in:
parent
66ca7345fd
commit
44c098ec5b
4
.rustfmt.toml
Normal file
4
.rustfmt.toml
Normal file
@ -0,0 +1,4 @@
|
||||
edition = "2018"
|
||||
|
||||
reorder_imports = false
|
||||
reorder_modules = false
|
@ -56,7 +56,7 @@ impl Default for FCEModuleConfig {
|
||||
wasi_version: WasiVersion::Latest,
|
||||
wasi_envs: vec![],
|
||||
wasi_preopened_files: vec![],
|
||||
wasi_mapped_dirs: vec![]
|
||||
wasi_mapped_dirs: vec![],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -72,16 +72,23 @@ impl std::fmt::Display for FCEError {
|
||||
FCEError::PrepareError(msg) => {
|
||||
write!(f, "Prepare error: {}, probably module is mailformed", msg)
|
||||
}
|
||||
FCEError::NonUniqueModuleName => {
|
||||
write!(f, "FCE already has module with such a name")
|
||||
}
|
||||
FCEError::NonUniqueModuleName => write!(f, "FCE already has module with such a name"),
|
||||
FCEError::NoSuchFunction(msg) => {
|
||||
write!(f, "FCE doesn't have a function with such a name: {}", msg)
|
||||
}
|
||||
FCEError::NoSuchModule => write!(f, "FCE doesn't have a module with such a name"),
|
||||
FCEError::NoWITSection => write!(f, "Loaded module doesn't contain WIT section that is neccessary for instantiation"),
|
||||
FCEError::MultipleWITSections => write!(f, "Loaded module contains multiple WIT sections that is unsupported now"),
|
||||
FCEError::WITRemainderNotEmpty => write!(f, "WIT section remainder isn't empty - WIT section possibly corrupted"),
|
||||
FCEError::NoWITSection => write!(
|
||||
f,
|
||||
"Loaded module doesn't contain WIT section that is neccessary for instantiation"
|
||||
),
|
||||
FCEError::MultipleWITSections => write!(
|
||||
f,
|
||||
"Loaded module contains multiple WIT sections that is unsupported now"
|
||||
),
|
||||
FCEError::WITRemainderNotEmpty => write!(
|
||||
f,
|
||||
"WIT section remainder isn't empty - WIT section possibly corrupted"
|
||||
),
|
||||
FCEError::WITParseError => write!(f, "WIT section is corrupted"),
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,12 @@ impl Default for FCE {
|
||||
}
|
||||
|
||||
impl FCEService for FCE {
|
||||
fn call(&mut self, module_name: &str, func_name: &str, argument: &[IValue]) -> Result<Vec<IValue>, FCEError> {
|
||||
fn call(
|
||||
&mut self,
|
||||
module_name: &str,
|
||||
func_name: &str,
|
||||
argument: &[IValue],
|
||||
) -> Result<Vec<IValue>, FCEError> {
|
||||
match self.modules.get_mut(module_name) {
|
||||
// TODO: refactor errors
|
||||
Some(mut module) => unsafe {
|
||||
@ -57,23 +62,19 @@ impl FCEService for FCE {
|
||||
wasm_bytes: &[u8],
|
||||
config: FCEModuleConfig,
|
||||
) -> Result<(), FCEError>
|
||||
where
|
||||
S: Into<String>,
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
let _prepared_wasm_bytes =
|
||||
super::prepare::prepare_module(wasm_bytes, config.mem_pages_count)?;
|
||||
|
||||
let module = FCEModule::new(
|
||||
&wasm_bytes,
|
||||
config.import_object,
|
||||
&self.modules,
|
||||
)?;
|
||||
let module = FCEModule::new(&wasm_bytes, config.import_object, &self.modules)?;
|
||||
|
||||
match self.modules.entry(module_name.into()) {
|
||||
Entry::Vacant(entry) => {
|
||||
entry.insert(Arc::new(module));
|
||||
Ok(())
|
||||
},
|
||||
}
|
||||
Entry::Occupied(_) => Err(FCEError::NonUniqueModuleName),
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,12 @@ use super::IValue;
|
||||
/// Describes a service behaviour in the Fluence network.
|
||||
pub trait FCEService {
|
||||
/// Invokes a module supplying byte array and expecting byte array with some outcome back.
|
||||
fn call(&mut self, module_name: &str, function_name: &str, arguments: &[IValue]) -> Result<Vec<IValue>, FCEError>;
|
||||
fn call(
|
||||
&mut self,
|
||||
module_name: &str,
|
||||
function_name: &str,
|
||||
arguments: &[IValue],
|
||||
) -> Result<Vec<IValue>, FCEError>;
|
||||
|
||||
/// Registers new module in the FCE Service.
|
||||
fn register_module<S>(
|
||||
|
@ -75,11 +75,7 @@ impl FCEModule {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn call(
|
||||
&mut self,
|
||||
function_name: &str,
|
||||
args: &[IValue],
|
||||
) -> Result<Vec<IValue>, FCEError> {
|
||||
pub fn call(&mut self, function_name: &str, args: &[IValue]) -> Result<Vec<IValue>, FCEError> {
|
||||
use wasmer_wit::interpreter::stack::Stackable;
|
||||
|
||||
match self.exports_funcs.get(function_name) {
|
||||
|
@ -15,7 +15,6 @@
|
||||
*/
|
||||
|
||||
/// Contains converters of types and values between Wasmer and wasmer_interface_types.
|
||||
|
||||
use super::{WType, WValue, IType, IValue};
|
||||
|
||||
pub(super) fn wtype_to_itype(ty: &WType) -> IType {
|
||||
|
@ -72,7 +72,10 @@ impl WITFunction {
|
||||
}
|
||||
|
||||
/// Creates function from a module import.
|
||||
pub(super) fn from_import(wit_module: Arc<FCEModule>, func_name: String) -> Result<Self, FCEError> {
|
||||
pub(super) fn from_import(
|
||||
wit_module: Arc<FCEModule>,
|
||||
func_name: String,
|
||||
) -> Result<Self, FCEError> {
|
||||
let func_type = wit_module.as_ref().get_func_signature(&func_name)?;
|
||||
let inputs = func_type.0.clone();
|
||||
let outputs = func_type.1.clone();
|
||||
|
@ -20,9 +20,7 @@ use super::fce_module::FCEModule;
|
||||
use wasmer_wit::interpreter::wasm;
|
||||
use super::IAstType;
|
||||
use wasmer_wit::ast::Interfaces;
|
||||
use wasmer_wit::interpreter::wasm::structures::{
|
||||
LocalImportIndex, TypedIndex,
|
||||
};
|
||||
use wasmer_wit::interpreter::wasm::structures::{LocalImportIndex, TypedIndex};
|
||||
use wasmer_core::Instance as WasmerInstance;
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
Loading…
Reference in New Issue
Block a user