mirror of
https://github.com/fluencelabs/aquavm
synced 2025-06-14 07:21:20 +00:00
Particle File Vault (#120)
This commit is contained in:
@ -51,15 +51,16 @@ pub fn create_avm(call_service: CallServiceClosure, current_peer_id: impl Into<S
|
||||
air_wasm_path: PathBuf::from("../target/wasm32-wasi/debug/air_interpreter_server.wasm"),
|
||||
call_service,
|
||||
current_peer_id: current_peer_id.into(),
|
||||
vault_dir: tmp_dir.join("vault"),
|
||||
particle_data_store: tmp_dir,
|
||||
logging_mask: i32::max_value(),
|
||||
logging_mask: i32::MAX,
|
||||
};
|
||||
|
||||
AVM::new(config).expect("vm should be created")
|
||||
}
|
||||
|
||||
pub fn unit_call_service() -> CallServiceClosure {
|
||||
Box::new(|_, _| -> Option<IValue> {
|
||||
Box::new(|_| -> Option<IValue> {
|
||||
Some(IValue::Record(
|
||||
NEVec::new(vec![
|
||||
IValue::S32(0),
|
||||
@ -71,8 +72,8 @@ pub fn unit_call_service() -> CallServiceClosure {
|
||||
}
|
||||
|
||||
pub fn echo_string_call_service() -> CallServiceClosure {
|
||||
Box::new(|_, args| -> Option<IValue> {
|
||||
let arg = match &args[2] {
|
||||
Box::new(|args| -> Option<IValue> {
|
||||
let arg = match &args.function_args[2] {
|
||||
IValue::String(str) => str,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
@ -87,8 +88,8 @@ pub fn echo_string_call_service() -> CallServiceClosure {
|
||||
}
|
||||
|
||||
pub fn echo_number_call_service() -> CallServiceClosure {
|
||||
Box::new(|_, args| -> Option<IValue> {
|
||||
let arg = match &args[2] {
|
||||
Box::new(|args| -> Option<IValue> {
|
||||
let arg = match &args.function_args[2] {
|
||||
IValue::String(str) => str,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
@ -103,7 +104,7 @@ pub fn echo_number_call_service() -> CallServiceClosure {
|
||||
|
||||
pub fn set_variable_call_service(json: impl Into<String>) -> CallServiceClosure {
|
||||
let json = json.into();
|
||||
Box::new(move |_, _| -> Option<IValue> {
|
||||
Box::new(move |_| -> Option<IValue> {
|
||||
Some(IValue::Record(
|
||||
NEVec::new(vec![IValue::S32(0), IValue::String(json.clone())]).unwrap(),
|
||||
))
|
||||
@ -111,8 +112,8 @@ pub fn set_variable_call_service(json: impl Into<String>) -> CallServiceClosure
|
||||
}
|
||||
|
||||
pub fn set_variables_call_service(ret_mapping: HashMap<String, String>) -> CallServiceClosure {
|
||||
Box::new(move |_, args| -> Option<IValue> {
|
||||
let arg_name = match &args[2] {
|
||||
Box::new(move |args| -> Option<IValue> {
|
||||
let arg_name = match &args.function_args[2] {
|
||||
IValue::String(json_str) => {
|
||||
let json = serde_json::from_str(json_str).expect("a valid json");
|
||||
match json {
|
||||
@ -140,8 +141,8 @@ pub fn set_variables_call_service(ret_mapping: HashMap<String, String>) -> CallS
|
||||
pub fn fallible_call_service(fallible_service_id: impl Into<String>) -> CallServiceClosure {
|
||||
let fallible_service_id = fallible_service_id.into();
|
||||
|
||||
Box::new(move |_, args| -> Option<IValue> {
|
||||
let builtin_service = match &args[0] {
|
||||
Box::new(move |args| -> Option<IValue> {
|
||||
let builtin_service = match &args.function_args[0] {
|
||||
IValue::String(str) => str,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
Reference in New Issue
Block a user