Skip to content

Commit 44c098e

Browse files
committed
add rustfmt config
1 parent 66ca734 commit 44c098e

9 files changed

+40
-27
lines changed

.rustfmt.toml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
edition = "2018"
2+
3+
reorder_imports = false
4+
reorder_modules = false

wit_fce/src/vm/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl Default for FCEModuleConfig {
5656
wasi_version: WasiVersion::Latest,
5757
wasi_envs: vec![],
5858
wasi_preopened_files: vec![],
59-
wasi_mapped_dirs: vec![]
59+
wasi_mapped_dirs: vec![],
6060
}
6161
}
6262
}

wit_fce/src/vm/errors.rs

+13-6
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,23 @@ impl std::fmt::Display for FCEError {
7272
FCEError::PrepareError(msg) => {
7373
write!(f, "Prepare error: {}, probably module is mailformed", msg)
7474
}
75-
FCEError::NonUniqueModuleName => {
76-
write!(f, "FCE already has module with such a name")
77-
}
75+
FCEError::NonUniqueModuleName => write!(f, "FCE already has module with such a name"),
7876
FCEError::NoSuchFunction(msg) => {
7977
write!(f, "FCE doesn't have a function with such a name: {}", msg)
8078
}
8179
FCEError::NoSuchModule => write!(f, "FCE doesn't have a module with such a name"),
82-
FCEError::NoWITSection => write!(f, "Loaded module doesn't contain WIT section that is neccessary for instantiation"),
83-
FCEError::MultipleWITSections => write!(f, "Loaded module contains multiple WIT sections that is unsupported now"),
84-
FCEError::WITRemainderNotEmpty => write!(f, "WIT section remainder isn't empty - WIT section possibly corrupted"),
80+
FCEError::NoWITSection => write!(
81+
f,
82+
"Loaded module doesn't contain WIT section that is neccessary for instantiation"
83+
),
84+
FCEError::MultipleWITSections => write!(
85+
f,
86+
"Loaded module contains multiple WIT sections that is unsupported now"
87+
),
88+
FCEError::WITRemainderNotEmpty => write!(
89+
f,
90+
"WIT section remainder isn't empty - WIT section possibly corrupted"
91+
),
8592
FCEError::WITParseError => write!(f, "WIT section is corrupted"),
8693
}
8794
}

wit_fce/src/vm/fce.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@ impl Default for FCE {
4141
}
4242

4343
impl FCEService for FCE {
44-
fn call(&mut self, module_name: &str, func_name: &str, argument: &[IValue]) -> Result<Vec<IValue>, FCEError> {
44+
fn call(
45+
&mut self,
46+
module_name: &str,
47+
func_name: &str,
48+
argument: &[IValue],
49+
) -> Result<Vec<IValue>, FCEError> {
4550
match self.modules.get_mut(module_name) {
4651
// TODO: refactor errors
4752
Some(mut module) => unsafe {
@@ -57,23 +62,19 @@ impl FCEService for FCE {
5762
wasm_bytes: &[u8],
5863
config: FCEModuleConfig,
5964
) -> Result<(), FCEError>
60-
where
61-
S: Into<String>,
65+
where
66+
S: Into<String>,
6267
{
6368
let _prepared_wasm_bytes =
6469
super::prepare::prepare_module(wasm_bytes, config.mem_pages_count)?;
6570

66-
let module = FCEModule::new(
67-
&wasm_bytes,
68-
config.import_object,
69-
&self.modules,
70-
)?;
71+
let module = FCEModule::new(&wasm_bytes, config.import_object, &self.modules)?;
7172

7273
match self.modules.entry(module_name.into()) {
7374
Entry::Vacant(entry) => {
7475
entry.insert(Arc::new(module));
7576
Ok(())
76-
},
77+
}
7778
Entry::Occupied(_) => Err(FCEError::NonUniqueModuleName),
7879
}
7980
}

wit_fce/src/vm/fce_service.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ use super::IValue;
2121
/// Describes a service behaviour in the Fluence network.
2222
pub trait FCEService {
2323
/// Invokes a module supplying byte array and expecting byte array with some outcome back.
24-
fn call(&mut self, module_name: &str, function_name: &str, arguments: &[IValue]) -> Result<Vec<IValue>, FCEError>;
24+
fn call(
25+
&mut self,
26+
module_name: &str,
27+
function_name: &str,
28+
arguments: &[IValue],
29+
) -> Result<Vec<IValue>, FCEError>;
2530

2631
/// Registers new module in the FCE Service.
2732
fn register_module<S>(

wit_fce/src/vm/instance/fce_module.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,7 @@ impl FCEModule {
7575
})
7676
}
7777

78-
pub fn call(
79-
&mut self,
80-
function_name: &str,
81-
args: &[IValue],
82-
) -> Result<Vec<IValue>, FCEError> {
78+
pub fn call(&mut self, function_name: &str, args: &[IValue]) -> Result<Vec<IValue>, FCEError> {
8379
use wasmer_wit::interpreter::stack::Stackable;
8480

8581
match self.exports_funcs.get(function_name) {

wit_fce/src/vm/instance/type_converters.rs

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616

1717
/// Contains converters of types and values between Wasmer and wasmer_interface_types.
18-
1918
use super::{WType, WValue, IType, IValue};
2019

2120
pub(super) fn wtype_to_itype(ty: &WType) -> IType {

wit_fce/src/vm/instance/wit_function.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ impl WITFunction {
7272
}
7373

7474
/// Creates function from a module import.
75-
pub(super) fn from_import(wit_module: Arc<FCEModule>, func_name: String) -> Result<Self, FCEError> {
75+
pub(super) fn from_import(
76+
wit_module: Arc<FCEModule>,
77+
func_name: String,
78+
) -> Result<Self, FCEError> {
7679
let func_type = wit_module.as_ref().get_func_signature(&func_name)?;
7780
let inputs = func_type.0.clone();
7881
let outputs = func_type.1.clone();

wit_fce/src/vm/instance/wit_instance.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ use super::fce_module::FCEModule;
2020
use wasmer_wit::interpreter::wasm;
2121
use super::IAstType;
2222
use wasmer_wit::ast::Interfaces;
23-
use wasmer_wit::interpreter::wasm::structures::{
24-
LocalImportIndex, TypedIndex,
25-
};
23+
use wasmer_wit::interpreter::wasm::structures::{LocalImportIndex, TypedIndex};
2624
use wasmer_core::Instance as WasmerInstance;
2725

2826
use std::collections::HashMap;

0 commit comments

Comments
 (0)