Array support (#28)

This commit is contained in:
vms
2020-09-23 01:14:54 +03:00
committed by GitHub
parent 8296486eaa
commit 58f14427f1
46 changed files with 870 additions and 243 deletions

View File

@ -10,7 +10,7 @@ jobs:
- checkout - checkout
- restore_cache: - restore_cache:
keys: keys:
- fce02-{{ checksum "Cargo.lock" }} - fce03-{{ checksum "Cargo.lock" }}
- run: | - run: |
rustup toolchain install nightly rustup toolchain install nightly
rustup component add rustfmt rustup component add rustfmt
@ -25,7 +25,7 @@ jobs:
paths: paths:
- ~/.cargo - ~/.cargo
- ~/.rustup - ~/.rustup
key: fce02-{{ checksum "Cargo.lock" }} key: fce03-{{ checksum "Cargo.lock" }}
examples: examples:
docker: docker:

4
.gitignore vendored
View File

@ -19,6 +19,6 @@ target/
!/examples/sqlite/artifacts/sqlite_test.wasm !/examples/sqlite/artifacts/sqlite_test.wasm
# Allowed Wasm files for test # Allowed Wasm files for test
!/fluence-faas/tests/json_wasm_tests/arguments_passing/artifacts/effector.wasm !/fluence-faas/tests/json_wasm_tests/arguments_passing/artifacts/*.wasm
!/fluence-faas/tests/json_wasm_tests/arguments_passing/artifacts/pure.wasm !/fluence-faas/tests/json_wasm_tests/arrays_passing/artifacts/*.wasm
!/fluence-faas/tests/json_wasm_tests/inner_records/artifacts/inner_records_pure.wasm !/fluence-faas/tests/json_wasm_tests/inner_records/artifacts/inner_records_pure.wasm

148
Cargo.lock generated
View File

@ -43,7 +43,7 @@ checksum = "6b602bfe940d21c130f3895acd65221e8a61270debe89d628b9cb4e3ccb8569b"
name = "arguments-passing-test" name = "arguments-passing-test"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"fluence 0.2.3 (git+https://github.com/fluencelabs/rust-sdk)", "fluence 0.2.7 (git+https://github.com/fluencelabs/rust-sdk)",
"safe-transmute", "safe-transmute",
] ]
@ -53,6 +53,14 @@ version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544"
[[package]]
name = "arrays-passing-test"
version = "0.1.0"
dependencies = [
"fluence 0.2.7 (git+https://github.com/fluencelabs/rust-sdk)",
"safe-transmute",
]
[[package]] [[package]]
name = "arrayvec" name = "arrayvec"
version = "0.5.1" version = "0.5.1"
@ -166,7 +174,7 @@ checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38"
name = "call_parameters" name = "call_parameters"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"fluence 0.2.3 (git+https://github.com/fluencelabs/rust-sdk)", "fluence 0.2.7 (git+https://github.com/fluencelabs/rust-sdk)",
] ]
[[package]] [[package]]
@ -363,9 +371,9 @@ dependencies = [
[[package]] [[package]]
name = "ctor" name = "ctor"
version = "0.1.15" version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39858aa5bac06462d4dd4b9164848eb81ffc4aa5c479746393598fd193afa227" checksum = "7fbaabec2c953050352311293be5c6aba8e141ba19d6811862b232d6fd020484"
dependencies = [ dependencies = [
"quote", "quote",
"syn", "syn",
@ -375,7 +383,7 @@ dependencies = [
name = "curl" name = "curl"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"fluence 0.2.3 (git+https://github.com/fluencelabs/rust-sdk)", "fluence 0.2.7 (git+https://github.com/fluencelabs/rust-sdk)",
"log", "log",
] ]
@ -599,7 +607,7 @@ dependencies = [
[[package]] [[package]]
name = "fce" name = "fce"
version = "0.1.5" version = "0.1.6"
dependencies = [ dependencies = [
"boolinator", "boolinator",
"bytes", "bytes",
@ -621,19 +629,19 @@ dependencies = [
[[package]] [[package]]
name = "fce-sqlite-connector" name = "fce-sqlite-connector"
version = "0.1.0" version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3931a7a9f133e94246ff2c36a14b66d3ea16e8460e715b982bd8974e56151b7b" checksum = "9481e1fd9af1eaae73b1f75b4c153e7ca22b8e0175defa97bedeef2d0b4fb8fc"
dependencies = [ dependencies = [
"fluence 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "fluence 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "fce-wit-generator" name = "fce-wit-generator"
version = "0.1.6" version = "0.1.7"
dependencies = [ dependencies = [
"fce-wit-parser", "fce-wit-parser",
"fluence-sdk-wit 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "fluence-sdk-wit 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
"once_cell", "once_cell",
"serde", "serde",
"serde_json", "serde_json",
@ -643,7 +651,7 @@ dependencies = [
[[package]] [[package]]
name = "fce-wit-interfaces" name = "fce-wit-interfaces"
version = "0.1.3" version = "0.1.4"
dependencies = [ dependencies = [
"multimap", "multimap",
"wasmer-interface-types-fl", "wasmer-interface-types-fl",
@ -651,7 +659,7 @@ dependencies = [
[[package]] [[package]]
name = "fce-wit-parser" name = "fce-wit-parser"
version = "0.1.5" version = "0.1.6"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"fce-wit-interfaces", "fce-wit-interfaces",
@ -662,7 +670,7 @@ dependencies = [
[[package]] [[package]]
name = "fcli" name = "fcli"
version = "0.1.7" version = "0.1.8"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"clap", "clap",
@ -675,26 +683,26 @@ dependencies = [
[[package]] [[package]]
name = "fluence" name = "fluence"
version = "0.2.3" version = "0.2.7"
source = "git+https://github.com/fluencelabs/rust-sdk#04e2538661bab57110a288a3c7d21a2905c377e4" source = "git+https://github.com/fluencelabs/rust-sdk#598080005d419b854172eda0168983854ad58b84"
dependencies = [ dependencies = [
"fluence-sdk-macro 0.2.3 (git+https://github.com/fluencelabs/rust-sdk)", "fluence-sdk-macro 0.2.7 (git+https://github.com/fluencelabs/rust-sdk)",
"fluence-sdk-main 0.2.3 (git+https://github.com/fluencelabs/rust-sdk)", "fluence-sdk-main 0.2.7 (git+https://github.com/fluencelabs/rust-sdk)",
] ]
[[package]] [[package]]
name = "fluence" name = "fluence"
version = "0.2.3" version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47a382fa3506247e84d799645523c56ebfcb4cdefb45671dd31f8664cfc86007" checksum = "f9cf5658bf53ea01ac94eff0bbcadd3df00db3086b07d0b34fd896134367597f"
dependencies = [ dependencies = [
"fluence-sdk-macro 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "fluence-sdk-macro 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
"fluence-sdk-main 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "fluence-sdk-main 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "fluence-app-service" name = "fluence-app-service"
version = "0.1.6" version = "0.1.7"
dependencies = [ dependencies = [
"fluence-faas", "fluence-faas",
"log", "log",
@ -705,12 +713,12 @@ dependencies = [
[[package]] [[package]]
name = "fluence-faas" name = "fluence-faas"
version = "0.1.6" version = "0.1.7"
dependencies = [ dependencies = [
"cmd_lib", "cmd_lib",
"env_logger 0.7.1", "env_logger 0.7.1",
"fce", "fce",
"fluence-sdk-main 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "fluence-sdk-main 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools", "itertools",
"log", "log",
"once_cell", "once_cell",
@ -727,46 +735,46 @@ dependencies = [
[[package]] [[package]]
name = "fluence-sdk-macro" name = "fluence-sdk-macro"
version = "0.2.3" version = "0.2.7"
source = "git+https://github.com/fluencelabs/rust-sdk#04e2538661bab57110a288a3c7d21a2905c377e4" source = "git+https://github.com/fluencelabs/rust-sdk#598080005d419b854172eda0168983854ad58b84"
dependencies = [ dependencies = [
"fluence-sdk-wit 0.2.3 (git+https://github.com/fluencelabs/rust-sdk)", "fluence-sdk-wit 0.2.7 (git+https://github.com/fluencelabs/rust-sdk)",
] ]
[[package]] [[package]]
name = "fluence-sdk-macro" name = "fluence-sdk-macro"
version = "0.2.3" version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c326f99a17dccf48e9cceadb7f19df184142d023f74ccb76634b8f99ac2dac1b" checksum = "a83b6b1993412964158956f56f72da7c1963e033a5c2e092a5bca811be9783bb"
dependencies = [ dependencies = [
"fluence-sdk-wit 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "fluence-sdk-wit 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "fluence-sdk-main" name = "fluence-sdk-main"
version = "0.2.3" version = "0.2.7"
source = "git+https://github.com/fluencelabs/rust-sdk#04e2538661bab57110a288a3c7d21a2905c377e4" source = "git+https://github.com/fluencelabs/rust-sdk#598080005d419b854172eda0168983854ad58b84"
dependencies = [ dependencies = [
"fluence-sdk-macro 0.2.3 (git+https://github.com/fluencelabs/rust-sdk)", "fluence-sdk-macro 0.2.7 (git+https://github.com/fluencelabs/rust-sdk)",
"log", "log",
"serde", "serde",
] ]
[[package]] [[package]]
name = "fluence-sdk-main" name = "fluence-sdk-main"
version = "0.2.3" version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8377076746dede55b132c745c5058630f164d9977d7f7dc4e414a837300cd9cc" checksum = "2827a4a8bf7fbe4c994affafecfeb7737791b598b5769a8d4c1e3a093a53b27d"
dependencies = [ dependencies = [
"fluence-sdk-macro 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "fluence-sdk-macro 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
"log", "log",
"serde", "serde",
] ]
[[package]] [[package]]
name = "fluence-sdk-wit" name = "fluence-sdk-wit"
version = "0.2.3" version = "0.2.7"
source = "git+https://github.com/fluencelabs/rust-sdk#04e2538661bab57110a288a3c7d21a2905c377e4" source = "git+https://github.com/fluencelabs/rust-sdk#598080005d419b854172eda0168983854ad58b84"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -778,9 +786,9 @@ dependencies = [
[[package]] [[package]]
name = "fluence-sdk-wit" name = "fluence-sdk-wit"
version = "0.2.3" version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7cb9034a9a196c94b12d650d07398c7e63ff83e98c120397f411da44156ab93a" checksum = "6dddd57ef9342dcd9b7ad553d9bd0724604958676b04b7c347f43a49e6d1ee43"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -813,7 +821,7 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
[[package]] [[package]]
name = "frepl" name = "frepl"
version = "0.1.9" version = "0.1.10"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"clap", "clap",
@ -1001,9 +1009,9 @@ dependencies = [
[[package]] [[package]]
name = "hermit-abi" name = "hermit-abi"
version = "0.1.15" version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3deed196b6e7f9e44a2ae8d94225d80302d81208b1bb673fd21fe634645c85a9" checksum = "4c30f6d0bc6b00693347368a67d41b58f2fb851215ff1da49e90fe2c5c667151"
dependencies = [ dependencies = [
"libc", "libc",
] ]
@ -1041,6 +1049,12 @@ version = "1.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9"
[[package]]
name = "httpdate"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "494b4d60369511e7dea41cf646832512a94e542f68bb9c49e54518e0f468eb47"
[[package]] [[package]]
name = "humantime" name = "humantime"
version = "1.3.0" version = "1.3.0"
@ -1052,9 +1066,9 @@ dependencies = [
[[package]] [[package]]
name = "hyper" name = "hyper"
version = "0.13.7" version = "0.13.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e68a8dd9716185d9e64ea473ea6ef63529252e3e27623295a0378a19665d5eb" checksum = "2f3afcfae8af5ad0576a31e768415edb627824129e8e5a29b8bfccb2f234e835"
dependencies = [ dependencies = [
"bytes", "bytes",
"futures-channel", "futures-channel",
@ -1064,10 +1078,10 @@ dependencies = [
"http", "http",
"http-body", "http-body",
"httparse", "httparse",
"httpdate",
"itoa", "itoa",
"pin-project", "pin-project",
"socket2", "socket2",
"time",
"tokio", "tokio",
"tower-service", "tower-service",
"tracing", "tracing",
@ -1125,7 +1139,7 @@ dependencies = [
name = "inner-records-test" name = "inner-records-test"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"fluence 0.2.3 (git+https://github.com/fluencelabs/rust-sdk)", "fluence 0.2.7 (git+https://github.com/fluencelabs/rust-sdk)",
"safe-transmute", "safe-transmute",
] ]
@ -1164,7 +1178,7 @@ dependencies = [
name = "ipfs-effector" name = "ipfs-effector"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"fluence 0.2.3 (git+https://github.com/fluencelabs/rust-sdk)", "fluence 0.2.7 (git+https://github.com/fluencelabs/rust-sdk)",
"log", "log",
] ]
@ -1172,7 +1186,7 @@ dependencies = [
name = "ipfs-pure" name = "ipfs-pure"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"fluence 0.2.3 (git+https://github.com/fluencelabs/rust-sdk)", "fluence 0.2.7 (git+https://github.com/fluencelabs/rust-sdk)",
"log", "log",
] ]
@ -1251,7 +1265,7 @@ checksum = "f2f96b10ec2560088a8e76961b00d47107b3a625fecb76dedb29ee7ccbf98235"
name = "local_storage" name = "local_storage"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"fluence 0.2.3 (git+https://github.com/fluencelabs/rust-sdk)", "fluence 0.2.7 (git+https://github.com/fluencelabs/rust-sdk)",
"log", "log",
] ]
@ -1303,9 +1317,9 @@ dependencies = [
[[package]] [[package]]
name = "memoffset" name = "memoffset"
version = "0.5.5" version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c198b026e1bbf08a937e94c6c60f9ec4a2267f5b0d2eec9c1b21b061ce2be55f" checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa"
dependencies = [ dependencies = [
"autocfg", "autocfg",
] ]
@ -1725,9 +1739,9 @@ dependencies = [
[[package]] [[package]]
name = "rayon-core" name = "rayon-core"
version = "1.8.0" version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91739a34c4355b5434ce54c9086c5895604a9c278586d1f1aa95e04f66b525a0" checksum = "e8c4fec834fb6e6d2dd5eece3c7b432a52f0ba887cf40e595190c4107edc08bf"
dependencies = [ dependencies = [
"crossbeam-channel", "crossbeam-channel",
"crossbeam-deque", "crossbeam-deque",
@ -1740,7 +1754,7 @@ dependencies = [
name = "record-effector" name = "record-effector"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"fluence 0.2.3 (git+https://github.com/fluencelabs/rust-sdk)", "fluence 0.2.7 (git+https://github.com/fluencelabs/rust-sdk)",
"test-record", "test-record",
] ]
@ -1748,7 +1762,7 @@ dependencies = [
name = "record-pure" name = "record-pure"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"fluence 0.2.3 (git+https://github.com/fluencelabs/rust-sdk)", "fluence 0.2.7 (git+https://github.com/fluencelabs/rust-sdk)",
"test-record", "test-record",
] ]
@ -2033,7 +2047,7 @@ name = "site-storage"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"fluence 0.2.3 (git+https://github.com/fluencelabs/rust-sdk)", "fluence 0.2.7 (git+https://github.com/fluencelabs/rust-sdk)",
"log", "log",
] ]
@ -2177,7 +2191,7 @@ dependencies = [
name = "test-record" name = "test-record"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"fluence 0.2.3 (git+https://github.com/fluencelabs/rust-sdk)", "fluence 0.2.7 (git+https://github.com/fluencelabs/rust-sdk)",
] ]
[[package]] [[package]]
@ -2360,9 +2374,9 @@ checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33"
[[package]] [[package]]
name = "typetag" name = "typetag"
version = "0.1.5" version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9275125decb5d75fe57ebfe92debd119b15757aae27c56d7cb61ecab871960bc" checksum = "83b97b107d25d29de6879ac4f676ac5bfea92bdd01f206e995794493f1fc2e32"
dependencies = [ dependencies = [
"erased-serde", "erased-serde",
"inventory", "inventory",
@ -2373,9 +2387,9 @@ dependencies = [
[[package]] [[package]]
name = "typetag-impl" name = "typetag-impl"
version = "0.1.5" version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc232cda3b1d82664153e6c95d1071809aa0f1011f306c3d6989f33d8c6ede17" checksum = "3f2466fc87b07b800a5060f89ba579d6882f7a03ac21363e4737764aaf9f99f9"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -2612,7 +2626,7 @@ checksum = "1d649a3145108d7d3fbcde896a468d1bd636791823c9921135218ad89be08307"
name = "wasm-greeting" name = "wasm-greeting"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"fluence 0.2.3 (git+https://github.com/fluencelabs/rust-sdk)", "fluence 0.2.7 (git+https://github.com/fluencelabs/rust-sdk)",
] ]
[[package]] [[package]]
@ -2620,7 +2634,7 @@ name = "wasm-sqlite-test"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"fce-sqlite-connector", "fce-sqlite-connector",
"fluence 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "fluence 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -2677,9 +2691,9 @@ dependencies = [
[[package]] [[package]]
name = "wasmer-interface-types-fl" name = "wasmer-interface-types-fl"
version = "0.17.6" version = "0.17.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e25c0eaef61611c9360026773456beb9da3773b0ed0e0a7362cf25f308e5755" checksum = "475cafb8bf9763895f6fde0d7417b9090145fc461ad7aef21b1a866b8357c091"
dependencies = [ dependencies = [
"log", "log",
"nom", "nom",

View File

@ -18,6 +18,7 @@ members = [
"fluence-app-service", "fluence-app-service",
"fluence-faas", "fluence-faas",
"fluence-faas/tests/json_wasm_tests/arguments_passing", "fluence-faas/tests/json_wasm_tests/arguments_passing",
"fluence-faas/tests/json_wasm_tests/arrays_passing",
"fluence-faas/tests/json_wasm_tests/inner_records", "fluence-faas/tests/json_wasm_tests/inner_records",
"tools/cli", "tools/cli",
"tools/repl", "tools/repl",

View File

@ -1,7 +1,7 @@
[package] [package]
name = "fce-wit-generator" name = "fce-wit-generator"
description = "Fluence FCE interface type helper crate" description = "Fluence FCE interface type helper crate"
version = "0.1.6" version = "0.1.7"
authors = ["Fluence Labs"] authors = ["Fluence Labs"]
license = "Apache-2.0" license = "Apache-2.0"
edition = "2018" edition = "2018"
@ -11,11 +11,11 @@ name = "fce_wit_generator"
path = "src/lib.rs" path = "src/lib.rs"
[dependencies] [dependencies]
fce-wit-parser = { path = "../wit-parser", version = "0.1.5"} fce-wit-parser = { path = "../wit-parser", version = "0.1.6"}
fluence-sdk-wit = "0.2.3" fluence-sdk-wit = "0.2.7"
walrus = "0.17.0" walrus = "0.17.0"
wasmer-wit = { package = "wasmer-interface-types-fl", version = "=0.17.6" } wasmer-wit = { package = "wasmer-interface-types-fl", version = "=0.17.9" }
once_cell = "1.4.0" once_cell = "1.4.0"
serde = { version = "1.0.110", features = ["derive"] } serde = { version = "1.0.110", features = ["derive"] }
serde_json = "1.0.56" serde_json = "1.0.56"

View File

@ -146,13 +146,15 @@ impl FnInstructionGenerator for ParsedType {
Instruction::ArgumentGet { index }, Instruction::ArgumentGet { index },
Instruction::StringLowerMemory, Instruction::StringLowerMemory,
], ],
ParsedType::ByteVector => vec![ ParsedType::Vector(value_type) => {
let value_type = ptype_to_itype_checked(value_type, wit_resolver)?;
vec![
Instruction::ArgumentGet { index }, Instruction::ArgumentGet { index },
Instruction::ByteArraySize, Instruction::ArrayLowerMemory {
Instruction::CallCore { function_index: ALLOCATE_FUNC.id }, value_type
Instruction::ArgumentGet { index }, },
Instruction::ByteArrayLowerMemory, ]
], },
ParsedType::Record(record_name) => { ParsedType::Record(record_name) => {
let record_type_id = wit_resolver.get_record_type_id(record_name)? as u32; let record_type_id = wit_resolver.get_record_type_id(record_name)? as u32;
@ -188,14 +190,15 @@ impl FnInstructionGenerator for ParsedType {
Instruction::CallCore { function_index: GET_RESULT_SIZE_FUNC.id }, Instruction::CallCore { function_index: GET_RESULT_SIZE_FUNC.id },
Instruction::CallCore { function_index: DEALLOCATE_FUNC.id }, Instruction::CallCore { function_index: DEALLOCATE_FUNC.id },
], ],
ParsedType::ByteVector => vec![ ParsedType::Vector(value_type) => {
let value_type = ptype_to_itype_checked(value_type, wit_resolver)?;
vec![
Instruction::CallCore { function_index: GET_RESULT_PTR_FUNC.id }, Instruction::CallCore { function_index: GET_RESULT_PTR_FUNC.id },
Instruction::CallCore { function_index: GET_RESULT_SIZE_FUNC.id }, Instruction::CallCore { function_index: GET_RESULT_SIZE_FUNC.id },
Instruction::ByteArrayLiftMemory, Instruction::ArrayLiftMemory { value_type },
Instruction::CallCore { function_index: GET_RESULT_PTR_FUNC.id }, ]
Instruction::CallCore { function_index: GET_RESULT_SIZE_FUNC.id }, },
Instruction::CallCore { function_index: DEALLOCATE_FUNC.id },
],
ParsedType::Record(record_name) => { ParsedType::Record(record_name) => {
let record_type_id = wit_resolver.get_record_type_id(record_name)? as u32; let record_type_id = wit_resolver.get_record_type_id(record_name)? as u32;

View File

@ -204,11 +204,15 @@ impl ForeignModInstructionGenerator for ParsedType {
Instruction::ArgumentGet { index: index + 1 }, Instruction::ArgumentGet { index: index + 1 },
Instruction::StringLiftMemory, Instruction::StringLiftMemory,
], 2), ], 2),
ParsedType::ByteVector => (vec![ ParsedType::Vector(value_type) => {
let value_type = ptype_to_itype_checked(value_type, wit_resolver)?;
(vec![
Instruction::ArgumentGet { index }, Instruction::ArgumentGet { index },
Instruction::ArgumentGet { index: index + 1 }, Instruction::ArgumentGet { index: index + 1 },
Instruction::ByteArrayLiftMemory, Instruction::ArrayLiftMemory { value_type },
], 2), ], 2)
},
ParsedType::Record(record_name) => { ParsedType::Record(record_name) => {
let record_type_id = wit_resolver.get_record_type_id(record_name)? as u32; let record_type_id = wit_resolver.get_record_type_id(record_name)? as u32;
@ -245,15 +249,15 @@ impl ForeignModInstructionGenerator for ParsedType {
Instruction::CallCore { function_index: SET_RESULT_SIZE_FUNC.id }, Instruction::CallCore { function_index: SET_RESULT_SIZE_FUNC.id },
Instruction::CallCore { function_index: SET_RESULT_PTR_FUNC.id }, Instruction::CallCore { function_index: SET_RESULT_PTR_FUNC.id },
], ],
ParsedType::ByteVector => vec![ ParsedType::Vector(value_type) => {
Instruction::Dup, let value_type = ptype_to_itype_checked(value_type, wit_resolver)?;
Instruction::ByteArraySize,
Instruction::CallCore { function_index: ALLOCATE_FUNC.id }, vec![
Instruction::Swap2, Instruction::ArrayLowerMemory { value_type },
Instruction::ByteArrayLowerMemory,
Instruction::CallCore { function_index: SET_RESULT_SIZE_FUNC.id }, Instruction::CallCore { function_index: SET_RESULT_SIZE_FUNC.id },
Instruction::CallCore { function_index: SET_RESULT_PTR_FUNC.id }, Instruction::CallCore { function_index: SET_RESULT_PTR_FUNC.id },
], ]
},
ParsedType::Record(record_name) => { ParsedType::Record(record_name) => {
let record_type_id = wit_resolver.get_record_type_id(record_name)? as u32; let record_type_id = wit_resolver.get_record_type_id(record_name)? as u32;
@ -296,7 +300,7 @@ pub fn to_raw_input_types(arg: &(String, ParsedType)) -> Vec<IFunctionArg> {
name: arg.0.clone(), name: arg.0.clone(),
ty: IType::F64, ty: IType::F64,
}], }],
ParsedType::Utf8String | ParsedType::ByteVector => vec![ ParsedType::Utf8String | ParsedType::Vector(_) => vec![
IFunctionArg { IFunctionArg {
name: format!("{}_ptr", arg.0), name: format!("{}_ptr", arg.0),
ty: IType::I32, ty: IType::I32,
@ -321,6 +325,6 @@ pub fn to_raw_output_type(ty: &ParsedType) -> Vec<RustType> {
ParsedType::I64 | ParsedType::U64 => vec![RustType::I64], ParsedType::I64 | ParsedType::U64 => vec![RustType::I64],
ParsedType::F32 => vec![RustType::F32], ParsedType::F32 => vec![RustType::F32],
ParsedType::F64 => vec![RustType::F64], ParsedType::F64 => vec![RustType::F64],
ParsedType::Utf8String | ParsedType::ByteVector | ParsedType::Record(_) => vec![], ParsedType::Utf8String | ParsedType::Vector(_) | ParsedType::Record(_) => vec![],
} }
} }

View File

@ -27,11 +27,26 @@ pub(crate) fn ptype_to_itype_checked(
wit_resolver: &mut WITResolver, wit_resolver: &mut WITResolver,
) -> Result<IType> { ) -> Result<IType> {
match pty { match pty {
ParsedType::I8 => Ok(IType::S8),
ParsedType::I16 => Ok(IType::S16),
ParsedType::I32 => Ok(IType::S32),
ParsedType::I64 => Ok(IType::S64),
ParsedType::U8 => Ok(IType::U8),
ParsedType::U16 => Ok(IType::U16),
ParsedType::U32 => Ok(IType::U32),
ParsedType::U64 => Ok(IType::U64),
ParsedType::F32 => Ok(IType::F32),
ParsedType::F64 => Ok(IType::F64),
ParsedType::Boolean => Ok(IType::I32),
ParsedType::Utf8String => Ok(IType::String),
ParsedType::Vector(ty) => {
let array_itype = ptype_to_itype_checked(ty, wit_resolver)?;
Ok(IType::Array(Box::new(array_itype)))
}
ParsedType::Record(record_name) => { ParsedType::Record(record_name) => {
let record_type_id = wit_resolver.get_record_type_id(record_name)?; let record_type_id = wit_resolver.get_record_type_id(record_name)?;
Ok(IType::Record(record_type_id as _)) Ok(IType::Record(record_type_id as _))
} }
_ => Ok(ptype_to_itype_unchecked(pty, wit_resolver)),
} }
} }
@ -49,7 +64,10 @@ pub(crate) fn ptype_to_itype_unchecked(pty: &ParsedType, wit_resolver: &mut WITR
ParsedType::F64 => IType::F64, ParsedType::F64 => IType::F64,
ParsedType::Boolean => IType::I32, ParsedType::Boolean => IType::I32,
ParsedType::Utf8String => IType::String, ParsedType::Utf8String => IType::String,
ParsedType::ByteVector => IType::ByteArray, ParsedType::Vector(ty) => {
let array_itype = ptype_to_itype_unchecked(ty, wit_resolver);
IType::Array(Box::new(array_itype))
}
ParsedType::Record(record_name) => { ParsedType::Record(record_name) => {
let record_type_id = wit_resolver.get_record_type_id_unchecked(record_name); let record_type_id = wit_resolver.get_record_type_id_unchecked(record_name);
IType::Record(record_type_id as _) IType::Record(record_type_id as _)

View File

@ -1,7 +1,7 @@
[package] [package]
name = "fce-wit-interfaces" name = "fce-wit-interfaces"
description = "Fluence FCE interface type helper crate" description = "Fluence FCE interface type helper crate"
version = "0.1.3" version = "0.1.4"
authors = ["Fluence Labs"] authors = ["Fluence Labs"]
license = "Apache-2.0" license = "Apache-2.0"
edition = "2018" edition = "2018"
@ -11,5 +11,5 @@ name = "fce_wit_interfaces"
path = "src/lib.rs" path = "src/lib.rs"
[dependencies] [dependencies]
wasmer-wit = { package = "wasmer-interface-types-fl", version = "=0.17.6" } wasmer-wit = { package = "wasmer-interface-types-fl", version = "=0.17.9" }
multimap = "0.8.1" multimap = "0.8.1"

View File

@ -1,7 +1,7 @@
[package] [package]
name = "fce-wit-parser" name = "fce-wit-parser"
description = "Fluence FCE interface type helper crate" description = "Fluence FCE interface type helper crate"
version = "0.1.5" version = "0.1.6"
authors = ["Fluence Labs"] authors = ["Fluence Labs"]
license = "Apache-2.0" license = "Apache-2.0"
edition = "2018" edition = "2018"
@ -11,9 +11,9 @@ name = "fce_wit_parser"
path = "src/lib.rs" path = "src/lib.rs"
[dependencies] [dependencies]
fce-wit-interfaces = { path = "../wit-interfaces", version = "0.1.3" } fce-wit-interfaces = { path = "../wit-interfaces", version = "0.1.4" }
anyhow = "1.0.31" anyhow = "1.0.31"
walrus = "0.17.0" walrus = "0.17.0"
wasmer-core = { package = "wasmer-runtime-core-fl", version = "0.17.0"} wasmer-core = { package = "wasmer-runtime-core-fl", version = "0.17.0"}
wasmer-wit = { package = "wasmer-interface-types-fl", version = "=0.17.6" } wasmer-wit = { package = "wasmer-interface-types-fl", version = "=0.17.9" }

View File

@ -1,7 +1,7 @@
[package] [package]
name = "fce" name = "fce"
description = "Fluence Compute Engine" description = "Fluence Compute Engine"
version = "0.1.5" version = "0.1.6"
authors = ["Fluence Labs"] authors = ["Fluence Labs"]
license = "Apache-2.0" license = "Apache-2.0"
edition = "2018" edition = "2018"
@ -11,13 +11,13 @@ name = "fce"
path = "src/lib.rs" path = "src/lib.rs"
[dependencies] [dependencies]
fce-wit-interfaces = { path = "../crates/wit-interfaces", version = "0.1.3" } fce-wit-interfaces = { path = "../crates/wit-interfaces", version = "0.1.4" }
fce-wit-parser = { path = "../crates/wit-parser", version = "0.1.5" } fce-wit-parser = { path = "../crates/wit-parser", version = "0.1.6" }
wasmer-runtime = { package = "wasmer-runtime-fl", version = "0.17.0" } wasmer-runtime = { package = "wasmer-runtime-fl", version = "0.17.0" }
# dynamicfunc-fat-closures allows using state inside DynamicFunc # dynamicfunc-fat-closures allows using state inside DynamicFunc
wasmer-core = { package = "wasmer-runtime-core-fl", version = "0.17.0", features = ["dynamicfunc-fat-closures"] } wasmer-core = { package = "wasmer-runtime-core-fl", version = "0.17.0", features = ["dynamicfunc-fat-closures"] }
wasmer-wit = { package = "wasmer-interface-types-fl", version = "=0.17.6" } wasmer-wit = { package = "wasmer-interface-types-fl", version = "=0.17.9" }
wasmer-wasi = { package = "wasmer-wasi-fl", version = "0.17.0" } wasmer-wasi = { package = "wasmer-wasi-fl", version = "0.17.0" }
multimap = "0.8.1" multimap = "0.8.1"

View File

@ -209,7 +209,8 @@ impl FCEModule {
arguments, arguments,
output_types, output_types,
} => { } => {
let interpreter: WITInterpreter = adapter_instructions.try_into()?; let interpreter: WITInterpreter =
adapter_instructions.clone().try_into()?;
let wit_module_func = WITModuleFunc { let wit_module_func = WITModuleFunc {
interpreter: Arc::new(interpreter), interpreter: Arc::new(interpreter),
arguments: arguments.clone(), arguments: arguments.clone(),
@ -330,7 +331,8 @@ impl FCEModule {
arguments, arguments,
output_types, output_types,
} => { } => {
let interpreter: WITInterpreter = adapter_instructions.try_into()?; let interpreter: WITInterpreter =
adapter_instructions.clone().try_into()?;
let raw_import = create_raw_import( let raw_import = create_raw_import(
wit_instance.clone(), wit_instance.clone(),

View File

@ -55,7 +55,7 @@ pub fn records() {
IValue::F32(9.0), IValue::F32(9.0),
IValue::F64(10.0), IValue::F64(10.0),
IValue::String(String::from("field_11")), IValue::String(String::from("field_11")),
IValue::ByteArray(vec![0x13, 0x37]) IValue::Array(vec![IValue::U8(0x13), IValue::U8(0x37)])
]) ])
.unwrap() .unwrap()
)] )]

View File

@ -9,5 +9,5 @@ name = "sqlite_test"
path = "src/main.rs" path = "src/main.rs"
[dependencies] [dependencies]
fluence = "0.2.3" fluence = "0.2.7"
fce-sqlite-connector = "0.1.0" fce-sqlite-connector = "0.1.1"

View File

@ -74,3 +74,23 @@ pub fn test2() {
println!("age = {}", row[1].as_integer().unwrap()); println!("age = {}", row[1].as_integer().unwrap());
} }
} }
#[fce]
pub fn test3() {
let db_path = "/tmp/users.sqlite";
let connection = fce_sqlite_connector::open(db_path).unwrap();
let execute_result = connection.execute(
"
CREATE TABLE users (name TEXT, age INTEGER);
INSERT INTO users VALUES ('Alice', 42);
INSERT INTO users VALUES ('Bob', 69);
",
);
println!("execute result: {:?}", execute_result);
let file_size = std::fs::metadata(db_path).unwrap().len();
println!("{} file size is {}", db_path, file_size);
}

View File

@ -1,13 +1,13 @@
[package] [package]
name = "fluence-app-service" name = "fluence-app-service"
description = "Fluence Application Service" description = "Fluence Application Service"
version = "0.1.6" version = "0.1.7"
authors = ["Fluence Labs"] authors = ["Fluence Labs"]
license = "Apache-2.0" license = "Apache-2.0"
edition = "2018" edition = "2018"
[dependencies] [dependencies]
fluence-faas = { path = "../fluence-faas", version = "0.1.6" } fluence-faas = { path = "../fluence-faas", version = "0.1.7" }
log = "0.4.8" log = "0.4.8"
serde_json = "1.0.53" serde_json = "1.0.53"

View File

@ -1,20 +1,20 @@
[package] [package]
name = "fluence-faas" name = "fluence-faas"
description = "Fluence FaaS" description = "Fluence FaaS"
version = "0.1.6" version = "0.1.7"
authors = ["Fluence Labs"] authors = ["Fluence Labs"]
license = "Apache-2.0" license = "Apache-2.0"
edition = "2018" edition = "2018"
[dependencies] [dependencies]
fce = { path = "../engine", version = "0.1.5" } fce = { path = "../engine", version = "0.1.6" }
fluence-sdk-main = "=0.2.3" fluence-sdk-main = "=0.2.7"
wasmer-runtime = { package = "wasmer-runtime-fl", version = "0.17.0" } wasmer-runtime = { package = "wasmer-runtime-fl", version = "0.17.0" }
# dynamicfunc-fat-closures allows using state inside DynamicFunc # dynamicfunc-fat-closures allows using state inside DynamicFunc
wasmer-core = { package = "wasmer-runtime-core-fl", version = "0.17.0", features = ["dynamicfunc-fat-closures"] } wasmer-core = { package = "wasmer-runtime-core-fl", version = "0.17.0", features = ["dynamicfunc-fat-closures"] }
wasmer-wasi = { package = "wasmer-wasi-fl", version = "0.17.0" } wasmer-wasi = { package = "wasmer-wasi-fl", version = "0.17.0" }
wasmer-wit = { package = "wasmer-interface-types-fl", version = "=0.17.6" } wasmer-wit = { package = "wasmer-interface-types-fl", version = "=0.17.9" }
toml = "0.5.6" toml = "0.5.6"
serde = { version = "1.0.111", features = ["derive"] } serde = { version = "1.0.111", features = ["derive"] }

View File

@ -68,7 +68,7 @@ impl<'a> fmt::Display for FaaSInterface<'a> {
writeln!(f, "\n{}:", *name)?; writeln!(f, "\n{}:", *name)?;
for (name, signature) in functions.iter() { for (name, signature) in functions.iter() {
write!(f, " pub fn {}(", name)?; write!(f, " fn {}(", name)?;
let args = signature let args = signature
.arguments .arguments

View File

@ -227,10 +227,25 @@ fn json_value_to_ivalue(
.map_err(FaaSError::ArgumentDeserializationError)?; .map_err(FaaSError::ArgumentDeserializationError)?;
Ok(IValue::String(value)) Ok(IValue::String(value))
} }
IType::ByteArray => { IType::Array(value_type) => {
let value = serde_json::from_value(json_value) let value = match json_value {
.map_err(FaaSError::ArgumentDeserializationError)?; SerdeValue::Array(json_array) => {
Ok(IValue::ByteArray(value)) let mut iargs = Vec::with_capacity(json_array.len());
for json_value in json_array {
let iarg = json_value_to_ivalue(json_value, value_type, record_types)?;
iargs.push(iarg);
}
Ok(iargs)
}
_ => Err(FaaSError::JsonArgumentsDeserializationError(format!(
"expected array of {:?} types, got {:?}",
value_type, json_value
))),
}?;
Ok(IValue::Array(value))
} }
IType::I32 => { IType::I32 => {
let value = serde_json::from_value(json_value) let value = serde_json::from_value(json_value)

View File

@ -16,6 +16,7 @@
use fluence_faas::FluenceFaaS; use fluence_faas::FluenceFaaS;
use fluence_faas::IValue; use fluence_faas::IValue;
use fluence_faas::IType;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use serde_json::json; use serde_json::json;
@ -44,9 +45,9 @@ pub fn get_interfaces() {
let string_type_arguments = vec![fluence_faas::IFunctionArg { let string_type_arguments = vec![fluence_faas::IFunctionArg {
name: String::from("arg"), name: String::from("arg"),
ty: fluence_faas::IType::String, ty: IType::String,
}]; }];
let string_type_output_types = vec![fluence_faas::IType::String]; let string_type_output_types = vec![IType::String];
let string_type_sign = fluence_faas::FaaSFunctionSignature { let string_type_sign = fluence_faas::FaaSFunctionSignature {
arguments: &string_type_arguments, arguments: &string_type_arguments,
@ -55,9 +56,9 @@ pub fn get_interfaces() {
let bytearray_type_arguments = vec![fluence_faas::IFunctionArg { let bytearray_type_arguments = vec![fluence_faas::IFunctionArg {
name: String::from("arg"), name: String::from("arg"),
ty: fluence_faas::IType::ByteArray, ty: IType::Array(Box::new(IType::U8)),
}]; }];
let bytearray_type_output_types = vec![fluence_faas::IType::ByteArray]; let bytearray_type_output_types = vec![IType::Array(Box::new(IType::U8))];
let bytearray_type_sign = fluence_faas::FaaSFunctionSignature { let bytearray_type_sign = fluence_faas::FaaSFunctionSignature {
arguments: &bytearray_type_arguments, arguments: &bytearray_type_arguments,
@ -66,9 +67,9 @@ pub fn get_interfaces() {
let i32_type_arguments = vec![fluence_faas::IFunctionArg { let i32_type_arguments = vec![fluence_faas::IFunctionArg {
name: String::from("arg"), name: String::from("arg"),
ty: fluence_faas::IType::S32, ty: IType::S32,
}]; }];
let i32_type_output_types = vec![fluence_faas::IType::S32]; let i32_type_output_types = vec![IType::S32];
let i32_type_sign = fluence_faas::FaaSFunctionSignature { let i32_type_sign = fluence_faas::FaaSFunctionSignature {
arguments: &i32_type_arguments, arguments: &i32_type_arguments,
@ -77,10 +78,10 @@ pub fn get_interfaces() {
let i64_type_arguments = vec![fluence_faas::IFunctionArg { let i64_type_arguments = vec![fluence_faas::IFunctionArg {
name: String::from("arg"), name: String::from("arg"),
ty: fluence_faas::IType::S64, ty: IType::S64,
}]; }];
let i64_type_output_types = vec![fluence_faas::IType::S64]; let i64_type_output_types = vec![IType::S64];
let i64_type_sign = fluence_faas::FaaSFunctionSignature { let i64_type_sign = fluence_faas::FaaSFunctionSignature {
arguments: &i64_type_arguments, arguments: &i64_type_arguments,
@ -89,9 +90,9 @@ pub fn get_interfaces() {
let u32_type_arguments = vec![fluence_faas::IFunctionArg { let u32_type_arguments = vec![fluence_faas::IFunctionArg {
name: String::from("arg"), name: String::from("arg"),
ty: fluence_faas::IType::U32, ty: IType::U32,
}]; }];
let u32_type_output_types = vec![fluence_faas::IType::U32]; let u32_type_output_types = vec![IType::U32];
let u32_type_sign = fluence_faas::FaaSFunctionSignature { let u32_type_sign = fluence_faas::FaaSFunctionSignature {
arguments: &u32_type_arguments, arguments: &u32_type_arguments,
@ -100,9 +101,9 @@ pub fn get_interfaces() {
let u64_type_arguments = vec![fluence_faas::IFunctionArg { let u64_type_arguments = vec![fluence_faas::IFunctionArg {
name: String::from("arg"), name: String::from("arg"),
ty: fluence_faas::IType::U64, ty: IType::U64,
}]; }];
let u64_type_output_types = vec![fluence_faas::IType::U64]; let u64_type_output_types = vec![IType::U64];
let u64_type_sign = fluence_faas::FaaSFunctionSignature { let u64_type_sign = fluence_faas::FaaSFunctionSignature {
arguments: &u64_type_arguments, arguments: &u64_type_arguments,
@ -111,9 +112,9 @@ pub fn get_interfaces() {
let f32_type_arguments = vec![fluence_faas::IFunctionArg { let f32_type_arguments = vec![fluence_faas::IFunctionArg {
name: String::from("arg"), name: String::from("arg"),
ty: fluence_faas::IType::F32, ty: IType::F32,
}]; }];
let f32_type_output_types = vec![fluence_faas::IType::F32]; let f32_type_output_types = vec![IType::F32];
let f32_type_sign = fluence_faas::FaaSFunctionSignature { let f32_type_sign = fluence_faas::FaaSFunctionSignature {
arguments: &f32_type_arguments, arguments: &f32_type_arguments,
@ -122,9 +123,9 @@ pub fn get_interfaces() {
let f64_type_arguments = vec![fluence_faas::IFunctionArg { let f64_type_arguments = vec![fluence_faas::IFunctionArg {
name: String::from("arg"), name: String::from("arg"),
ty: fluence_faas::IType::F64, ty: IType::F64,
}]; }];
let f64_type_output_types = vec![fluence_faas::IType::F64]; let f64_type_output_types = vec![IType::F64];
let f64_type_sign = fluence_faas::FaaSFunctionSignature { let f64_type_sign = fluence_faas::FaaSFunctionSignature {
arguments: &f64_type_arguments, arguments: &f64_type_arguments,
@ -132,7 +133,7 @@ pub fn get_interfaces() {
}; };
let empty_type_arguments = vec![]; let empty_type_arguments = vec![];
let empty_type_output_types = vec![fluence_faas::IType::String]; let empty_type_output_types = vec![IType::String];
let empty_type_sign = fluence_faas::FaaSFunctionSignature { let empty_type_sign = fluence_faas::FaaSFunctionSignature {
arguments: &empty_type_arguments, arguments: &empty_type_arguments,
@ -141,9 +142,9 @@ pub fn get_interfaces() {
let bool_type_arguments = vec![fluence_faas::IFunctionArg { let bool_type_arguments = vec![fluence_faas::IFunctionArg {
name: String::from("arg"), name: String::from("arg"),
ty: fluence_faas::IType::I32, ty: IType::I32,
}]; }];
let bool_type_output_types = vec![fluence_faas::IType::I32]; let bool_type_output_types = vec![IType::I32];
let bool_type_sign = fluence_faas::FaaSFunctionSignature { let bool_type_sign = fluence_faas::FaaSFunctionSignature {
arguments: &bool_type_arguments, arguments: &bool_type_arguments,
@ -153,54 +154,54 @@ pub fn get_interfaces() {
let all_types_arguments = vec![ let all_types_arguments = vec![
fluence_faas::IFunctionArg { fluence_faas::IFunctionArg {
name: String::from("arg_0"), name: String::from("arg_0"),
ty: fluence_faas::IType::S8, ty: IType::S8,
}, },
fluence_faas::IFunctionArg { fluence_faas::IFunctionArg {
name: String::from("arg_1"), name: String::from("arg_1"),
ty: fluence_faas::IType::S16, ty: IType::S16,
}, },
fluence_faas::IFunctionArg { fluence_faas::IFunctionArg {
name: String::from("arg_2"), name: String::from("arg_2"),
ty: fluence_faas::IType::S32, ty: IType::S32,
}, },
fluence_faas::IFunctionArg { fluence_faas::IFunctionArg {
name: String::from("arg_3"), name: String::from("arg_3"),
ty: fluence_faas::IType::S64, ty: IType::S64,
}, },
fluence_faas::IFunctionArg { fluence_faas::IFunctionArg {
name: String::from("arg_4"), name: String::from("arg_4"),
ty: fluence_faas::IType::U8, ty: IType::U8,
}, },
fluence_faas::IFunctionArg { fluence_faas::IFunctionArg {
name: String::from("arg_5"), name: String::from("arg_5"),
ty: fluence_faas::IType::U16, ty: IType::U16,
}, },
fluence_faas::IFunctionArg { fluence_faas::IFunctionArg {
name: String::from("arg_6"), name: String::from("arg_6"),
ty: fluence_faas::IType::U32, ty: IType::U32,
}, },
fluence_faas::IFunctionArg { fluence_faas::IFunctionArg {
name: String::from("arg_7"), name: String::from("arg_7"),
ty: fluence_faas::IType::U64, ty: IType::U64,
}, },
fluence_faas::IFunctionArg { fluence_faas::IFunctionArg {
name: String::from("arg_8"), name: String::from("arg_8"),
ty: fluence_faas::IType::F32, ty: IType::F32,
}, },
fluence_faas::IFunctionArg { fluence_faas::IFunctionArg {
name: String::from("arg_9"), name: String::from("arg_9"),
ty: fluence_faas::IType::F64, ty: IType::F64,
}, },
fluence_faas::IFunctionArg { fluence_faas::IFunctionArg {
name: String::from("arg_10"), name: String::from("arg_10"),
ty: fluence_faas::IType::String, ty: IType::String,
}, },
fluence_faas::IFunctionArg { fluence_faas::IFunctionArg {
name: String::from("arg_11"), name: String::from("arg_11"),
ty: fluence_faas::IType::ByteArray, ty: IType::Array(Box::new(IType::U8)),
}, },
]; ];
let all_types_output_types = vec![fluence_faas::IType::ByteArray]; let all_types_output_types = vec![IType::Array(Box::new(IType::U8))];
let all_types_sign = fluence_faas::FaaSFunctionSignature { let all_types_sign = fluence_faas::FaaSFunctionSignature {
arguments: &all_types_arguments, arguments: &all_types_arguments,
@ -221,8 +222,8 @@ pub fn get_interfaces() {
functions.insert("all_types", all_types_sign); functions.insert("all_types", all_types_sign);
let mut modules = std::collections::HashMap::new(); let mut modules = std::collections::HashMap::new();
modules.insert("pure", functions.clone()); modules.insert("arguments_passing_pure", functions.clone());
modules.insert("effector", functions); modules.insert("arguments_passing_effector", functions);
assert_eq!( assert_eq!(
interface, interface,
@ -238,15 +239,25 @@ pub fn all_types() {
let mut faas = FluenceFaaS::with_raw_config(ARG_CONFIG.clone()) let mut faas = FluenceFaaS::with_raw_config(ARG_CONFIG.clone())
.unwrap_or_else(|e| panic!("can't create Fluence FaaS instance: {:?}", e)); .unwrap_or_else(|e| panic!("can't create Fluence FaaS instance: {:?}", e));
let result1 = faas.call_with_json("pure", "all_types", json!({}), <_>::default()); let result1 = faas.call_with_json(
"arguments_passing_pure",
"all_types",
json!({}),
<_>::default(),
);
assert!(result1.is_err()); assert!(result1.is_err());
let result2 = faas.call_with_json("pure", "all_types", json!([]), <_>::default()); let result2 = faas.call_with_json(
"arguments_passing_pure",
"all_types",
json!([]),
<_>::default(),
);
assert!(result2.is_err()); assert!(result2.is_err());
let result3 = faas let result3 = faas
.call_with_json( .call_with_json(
"pure", "arguments_passing_pure",
"all_types", "all_types",
json!({ json!({
"arg_0": 0, "arg_0": 0,
@ -267,18 +278,23 @@ pub fn all_types() {
.unwrap_or_else(|e| panic!("can't invoke all_types: {:?}", e)); .unwrap_or_else(|e| panic!("can't invoke all_types: {:?}", e));
assert_eq!( assert_eq!(
result3, result3,
vec![IValue::ByteArray(vec![ vec![IValue::Array(
0, 1, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 4, 5, 0, 6, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, vec![
0, 65, 1, 153, 154, 64, 34, 51, 51, 51, 51, 51, 51, 102, 108, 117, 101, 110, 99, 101, 0, 1, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 4, 5, 0, 6, 0, 0, 0, 7, 0, 0, 0, 0, 0,
19, 55, 0, 1, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 4, 5, 0, 6, 0, 0, 0, 7, 0, 0, 0, 0, 0, 65, 1, 153, 154, 64, 34, 51, 51, 51, 51, 51, 51, 102, 108, 117, 101, 110, 99,
0, 0, 0, 0, 65, 1, 153, 154, 64, 34, 51, 51, 51, 51, 51, 51, 102, 108, 117, 101, 110, 101, 19, 55, 0, 1, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 4, 5, 0, 6, 0, 0, 0, 7,
99, 101, 19, 55 0, 0, 0, 0, 0, 0, 0, 65, 1, 153, 154, 64, 34, 51, 51, 51, 51, 51, 51, 102, 108,
])] 117, 101, 110, 99, 101, 19, 55
]
.iter()
.map(|v| IValue::U8(*v))
.collect::<Vec<_>>()
)]
); );
let result4 = faas let result4 = faas
.call_with_json( .call_with_json(
"pure", "arguments_passing_pure",
"all_types", "all_types",
json!([ json!([
0, 0,
@ -299,13 +315,18 @@ pub fn all_types() {
.unwrap_or_else(|e| panic!("can't invoke all_types: {:?}", e)); .unwrap_or_else(|e| panic!("can't invoke all_types: {:?}", e));
assert_eq!( assert_eq!(
result4, result4,
vec![IValue::ByteArray(vec![ vec![IValue::Array(
0, 1, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 4, 5, 0, 6, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, vec![
0, 65, 1, 153, 154, 64, 34, 51, 51, 51, 51, 51, 51, 102, 108, 117, 101, 110, 99, 101, 0, 1, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 4, 5, 0, 6, 0, 0, 0, 7, 0, 0, 0, 0, 0,
19, 55, 0, 1, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 4, 5, 0, 6, 0, 0, 0, 7, 0, 0, 0, 0, 0, 65, 1, 153, 154, 64, 34, 51, 51, 51, 51, 51, 51, 102, 108, 117, 101, 110, 99,
0, 0, 0, 0, 65, 1, 153, 154, 64, 34, 51, 51, 51, 51, 51, 51, 102, 108, 117, 101, 110, 101, 19, 55, 0, 1, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 4, 5, 0, 6, 0, 0, 0, 7,
99, 101, 19, 55 0, 0, 0, 0, 0, 0, 0, 65, 1, 153, 154, 64, 34, 51, 51, 51, 51, 51, 51, 102, 108,
])] 117, 101, 110, 99, 101, 19, 55
]
.iter()
.map(|v| IValue::U8(*v))
.collect::<Vec<_>>()
)]
); );
} }
@ -314,19 +335,39 @@ pub fn i32_type() {
let mut faas = FluenceFaaS::with_raw_config(ARG_CONFIG.clone()) let mut faas = FluenceFaaS::with_raw_config(ARG_CONFIG.clone())
.unwrap_or_else(|e| panic!("can't create Fluence FaaS instance: {:?}", e)); .unwrap_or_else(|e| panic!("can't create Fluence FaaS instance: {:?}", e));
let result1 = faas.call_with_json("pure", "i32_type", json!({}), <_>::default()); let result1 = faas.call_with_json(
"arguments_passing_pure",
"i32_type",
json!({}),
<_>::default(),
);
assert!(result1.is_err()); assert!(result1.is_err());
let result2 = faas.call_with_json("pure", "i32_type", json!([]), <_>::default()); let result2 = faas.call_with_json(
"arguments_passing_pure",
"i32_type",
json!([]),
<_>::default(),
);
assert!(result2.is_err()); assert!(result2.is_err());
let result3 = faas let result3 = faas
.call_with_json("pure", "i32_type", json!({ "arg": 1 }), <_>::default()) .call_with_json(
"arguments_passing_pure",
"i32_type",
json!({ "arg": 1 }),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke i32_type: {:?}", e)); .unwrap_or_else(|e| panic!("can't invoke i32_type: {:?}", e));
assert_eq!(result3, vec![IValue::S32(3)]); assert_eq!(result3, vec![IValue::S32(3)]);
let result4 = faas let result4 = faas
.call_with_json("pure", "i32_type", json!(1), <_>::default()) .call_with_json(
"arguments_passing_pure",
"i32_type",
json!(1),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke i32_type: {:?}", e)); .unwrap_or_else(|e| panic!("can't invoke i32_type: {:?}", e));
assert_eq!(result4, vec![IValue::S32(3)]); assert_eq!(result4, vec![IValue::S32(3)]);
} }
@ -336,19 +377,39 @@ pub fn i64_type() {
let mut faas = FluenceFaaS::with_raw_config(ARG_CONFIG.clone()) let mut faas = FluenceFaaS::with_raw_config(ARG_CONFIG.clone())
.unwrap_or_else(|e| panic!("can't create Fluence FaaS instance: {:?}", e)); .unwrap_or_else(|e| panic!("can't create Fluence FaaS instance: {:?}", e));
let result1 = faas.call_with_json("pure", "i64_type", json!({}), <_>::default()); let result1 = faas.call_with_json(
"arguments_passing_pure",
"i64_type",
json!({}),
<_>::default(),
);
assert!(result1.is_err()); assert!(result1.is_err());
let result2 = faas.call_with_json("pure", "i64_type", json!([]), <_>::default()); let result2 = faas.call_with_json(
"arguments_passing_pure",
"i64_type",
json!([]),
<_>::default(),
);
assert!(result2.is_err()); assert!(result2.is_err());
let result3 = faas let result3 = faas
.call_with_json("pure", "i64_type", json!({ "arg": 1 }), <_>::default()) .call_with_json(
"arguments_passing_pure",
"i64_type",
json!({ "arg": 1 }),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke i64_type: {:?}", e)); .unwrap_or_else(|e| panic!("can't invoke i64_type: {:?}", e));
assert_eq!(result3, vec![IValue::S64(3)]); assert_eq!(result3, vec![IValue::S64(3)]);
let result4 = faas let result4 = faas
.call_with_json("pure", "i64_type", json!(1), <_>::default()) .call_with_json(
"arguments_passing_pure",
"i64_type",
json!(1),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke i64_type: {:?}", e)); .unwrap_or_else(|e| panic!("can't invoke i64_type: {:?}", e));
assert_eq!(result4, vec![IValue::S64(3)]); assert_eq!(result4, vec![IValue::S64(3)]);
} }
@ -358,19 +419,39 @@ pub fn u32_type() {
let mut faas = FluenceFaaS::with_raw_config(ARG_CONFIG.clone()) let mut faas = FluenceFaaS::with_raw_config(ARG_CONFIG.clone())
.unwrap_or_else(|e| panic!("can't create Fluence FaaS instance: {:?}", e)); .unwrap_or_else(|e| panic!("can't create Fluence FaaS instance: {:?}", e));
let result1 = faas.call_with_json("pure", "u32_type", json!({}), <_>::default()); let result1 = faas.call_with_json(
"arguments_passing_pure",
"u32_type",
json!({}),
<_>::default(),
);
assert!(result1.is_err()); assert!(result1.is_err());
let result2 = faas.call_with_json("pure", "u32_type", json!([]), <_>::default()); let result2 = faas.call_with_json(
"arguments_passing_pure",
"u32_type",
json!([]),
<_>::default(),
);
assert!(result2.is_err()); assert!(result2.is_err());
let result3 = faas let result3 = faas
.call_with_json("pure", "u32_type", json!({ "arg": 1 }), <_>::default()) .call_with_json(
"arguments_passing_pure",
"u32_type",
json!({ "arg": 1 }),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke u32_type: {:?}", e)); .unwrap_or_else(|e| panic!("can't invoke u32_type: {:?}", e));
assert_eq!(result3, vec![IValue::U32(3)]); assert_eq!(result3, vec![IValue::U32(3)]);
let result4 = faas let result4 = faas
.call_with_json("pure", "u32_type", json!(1), <_>::default()) .call_with_json(
"arguments_passing_pure",
"u32_type",
json!(1),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke u32_type: {:?}", e)); .unwrap_or_else(|e| panic!("can't invoke u32_type: {:?}", e));
assert_eq!(result4, vec![IValue::U32(3)]); assert_eq!(result4, vec![IValue::U32(3)]);
} }
@ -380,19 +461,39 @@ pub fn u64_type() {
let mut faas = FluenceFaaS::with_raw_config(ARG_CONFIG.clone()) let mut faas = FluenceFaaS::with_raw_config(ARG_CONFIG.clone())
.unwrap_or_else(|e| panic!("can't create Fluence FaaS instance: {:?}", e)); .unwrap_or_else(|e| panic!("can't create Fluence FaaS instance: {:?}", e));
let result1 = faas.call_with_json("pure", "u64_type", json!({}), <_>::default()); let result1 = faas.call_with_json(
"arguments_passing_pure",
"u64_type",
json!({}),
<_>::default(),
);
assert!(result1.is_err()); assert!(result1.is_err());
let result2 = faas.call_with_json("pure", "u64_type", json!([]), <_>::default()); let result2 = faas.call_with_json(
"arguments_passing_pure",
"u64_type",
json!([]),
<_>::default(),
);
assert!(result2.is_err()); assert!(result2.is_err());
let result3 = faas let result3 = faas
.call_with_json("pure", "u64_type", json!({ "arg": 1 }), <_>::default()) .call_with_json(
"arguments_passing_pure",
"u64_type",
json!({ "arg": 1 }),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke u64_type: {:?}", e)); .unwrap_or_else(|e| panic!("can't invoke u64_type: {:?}", e));
assert_eq!(result3, vec![IValue::U64(3)]); assert_eq!(result3, vec![IValue::U64(3)]);
let result4 = faas let result4 = faas
.call_with_json("pure", "u64_type", json!(1), <_>::default()) .call_with_json(
"arguments_passing_pure",
"u64_type",
json!(1),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke u64_type: {:?}", e)); .unwrap_or_else(|e| panic!("can't invoke u64_type: {:?}", e));
assert_eq!(result4, vec![IValue::U64(3)]); assert_eq!(result4, vec![IValue::U64(3)]);
} }
@ -402,19 +503,39 @@ pub fn f32_type() {
let mut faas = FluenceFaaS::with_raw_config(ARG_CONFIG.clone()) let mut faas = FluenceFaaS::with_raw_config(ARG_CONFIG.clone())
.unwrap_or_else(|e| panic!("can't create Fluence FaaS instance: {:?}", e)); .unwrap_or_else(|e| panic!("can't create Fluence FaaS instance: {:?}", e));
let result1 = faas.call_with_json("pure", "f32_type", json!({}), <_>::default()); let result1 = faas.call_with_json(
"arguments_passing_pure",
"f32_type",
json!({}),
<_>::default(),
);
assert!(result1.is_err()); assert!(result1.is_err());
let result2 = faas.call_with_json("pure", "f32_type", json!([]), <_>::default()); let result2 = faas.call_with_json(
"arguments_passing_pure",
"f32_type",
json!([]),
<_>::default(),
);
assert!(result2.is_err()); assert!(result2.is_err());
let result3 = faas let result3 = faas
.call_with_json("pure", "f32_type", json!({ "arg": 1.0 }), <_>::default()) .call_with_json(
"arguments_passing_pure",
"f32_type",
json!({ "arg": 1.0 }),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke f32_type: {:?}", e)); .unwrap_or_else(|e| panic!("can't invoke f32_type: {:?}", e));
assert_eq!(result3, vec![IValue::F32(3.0)]); assert_eq!(result3, vec![IValue::F32(3.0)]);
let result4 = faas let result4 = faas
.call_with_json("pure", "f32_type", json!(1.0), <_>::default()) .call_with_json(
"arguments_passing_pure",
"f32_type",
json!(1.0),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke f32_type: {:?}", e)); .unwrap_or_else(|e| panic!("can't invoke f32_type: {:?}", e));
assert_eq!(result4, vec![IValue::F32(3.0)]); assert_eq!(result4, vec![IValue::F32(3.0)]);
} }
@ -424,19 +545,39 @@ pub fn f64_type() {
let mut faas = FluenceFaaS::with_raw_config(ARG_CONFIG.clone()) let mut faas = FluenceFaaS::with_raw_config(ARG_CONFIG.clone())
.unwrap_or_else(|e| panic!("can't create Fluence FaaS instance: {:?}", e)); .unwrap_or_else(|e| panic!("can't create Fluence FaaS instance: {:?}", e));
let result1 = faas.call_with_json("pure", "f64_type", json!({}), <_>::default()); let result1 = faas.call_with_json(
"arguments_passing_pure",
"f64_type",
json!({}),
<_>::default(),
);
assert!(result1.is_err()); assert!(result1.is_err());
let result2 = faas.call_with_json("pure", "f64_type", json!([]), <_>::default()); let result2 = faas.call_with_json(
"arguments_passing_pure",
"f64_type",
json!([]),
<_>::default(),
);
assert!(result2.is_err()); assert!(result2.is_err());
let result3 = faas let result3 = faas
.call_with_json("pure", "f64_type", json!({ "arg": 1.0 }), <_>::default()) .call_with_json(
"arguments_passing_pure",
"f64_type",
json!({ "arg": 1.0 }),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke f64_type: {:?}", e)); .unwrap_or_else(|e| panic!("can't invoke f64_type: {:?}", e));
assert_eq!(result3, vec![IValue::F64(3.0)]); assert_eq!(result3, vec![IValue::F64(3.0)]);
let result4 = faas let result4 = faas
.call_with_json("pure", "f64_type", json!(1.0), <_>::default()) .call_with_json(
"arguments_passing_pure",
"f64_type",
json!(1.0),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke f64_type: {:?}", e)); .unwrap_or_else(|e| panic!("can't invoke f64_type: {:?}", e));
assert_eq!(result4, vec![IValue::F64(3.0)]); assert_eq!(result4, vec![IValue::F64(3.0)]);
} }
@ -446,15 +587,25 @@ pub fn string_type() {
let mut faas = FluenceFaaS::with_raw_config(ARG_CONFIG.clone()) let mut faas = FluenceFaaS::with_raw_config(ARG_CONFIG.clone())
.unwrap_or_else(|e| panic!("can't create Fluence FaaS instance: {:?}", e)); .unwrap_or_else(|e| panic!("can't create Fluence FaaS instance: {:?}", e));
let result1 = faas.call_with_json("pure", "string_type", json!({}), <_>::default()); let result1 = faas.call_with_json(
"arguments_passing_pure",
"string_type",
json!({}),
<_>::default(),
);
assert!(result1.is_err()); assert!(result1.is_err());
let result2 = faas.call_with_json("pure", "string_type", json!([]), <_>::default()); let result2 = faas.call_with_json(
"arguments_passing_pure",
"string_type",
json!([]),
<_>::default(),
);
assert!(result2.is_err()); assert!(result2.is_err());
let result3 = faas let result3 = faas
.call_with_json( .call_with_json(
"pure", "arguments_passing_pure",
"string_type", "string_type",
json!({ "arg": "Fluence" }), json!({ "arg": "Fluence" }),
<_>::default(), <_>::default(),
@ -468,7 +619,12 @@ pub fn string_type() {
); );
let result4 = faas let result4 = faas
.call_with_json("pure", "string_type", json!("Fluence"), <_>::default()) .call_with_json(
"arguments_passing_pure",
"string_type",
json!("Fluence"),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke string_type: {:?}", e)); .unwrap_or_else(|e| panic!("can't invoke string_type: {:?}", e));
assert_eq!( assert_eq!(
result4, result4,
@ -483,31 +639,57 @@ pub fn bytearray_type() {
let mut faas = FluenceFaaS::with_raw_config(ARG_CONFIG.clone()) let mut faas = FluenceFaaS::with_raw_config(ARG_CONFIG.clone())
.unwrap_or_else(|e| panic!("can't create Fluence FaaS instance: {:?}", e)); .unwrap_or_else(|e| panic!("can't create Fluence FaaS instance: {:?}", e));
let result1 = faas.call_with_json("pure", "bytearray_type", json!({}), <_>::default()); let result1 = faas.call_with_json(
"arguments_passing_pure",
"bytearray_type",
json!({}),
<_>::default(),
);
assert!(result1.is_err()); assert!(result1.is_err());
let result2 = faas.call_with_json("pure", "bytearray_type", json!([]), <_>::default()); let result2 = faas.call_with_json(
"arguments_passing_pure",
"bytearray_type",
json!([]),
<_>::default(),
);
assert!(result2.is_err()); assert!(result2.is_err());
let result3 = faas let result3 = faas
.call_with_json( .call_with_json(
"pure", "arguments_passing_pure",
"bytearray_type", "bytearray_type",
json!({ "arg": [0x13, 0x37] }), json!({ "arg": [0x13, 0x37] }),
<_>::default(), <_>::default(),
) )
.unwrap_or_else(|e| panic!("can't invoke bytearray_type: {:?}", e)); .unwrap_or_else(|e| panic!("can't invoke bytearray_type: {:?}", e));
assert_eq!(result3, vec![IValue::ByteArray(vec![0x13, 0x37, 0x1, 0x1])]); assert_eq!(
result3,
vec![IValue::Array(vec![
IValue::U8(0x13),
IValue::U8(0x37),
IValue::U8(1),
IValue::U8(1)
])]
);
let result4 = faas let result4 = faas
.call_with_json( .call_with_json(
"pure", "arguments_passing_pure",
"bytearray_type", "bytearray_type",
json!([[0x13, 0x37]]), json!([[0x13, 0x37]]),
<_>::default(), <_>::default(),
) )
.unwrap_or_else(|e| panic!("can't invoke bytearray_type: {:?}", e)); .unwrap_or_else(|e| panic!("can't invoke bytearray_type: {:?}", e));
assert_eq!(result4, vec![IValue::ByteArray(vec![0x13, 0x37, 0x1, 0x1])]); assert_eq!(
result4,
vec![IValue::Array(vec![
IValue::U8(0x13),
IValue::U8(0x37),
IValue::U8(1),
IValue::U8(1)
])]
);
} }
#[test] #[test]
@ -515,19 +697,39 @@ pub fn bool_type() {
let mut faas = FluenceFaaS::with_raw_config(ARG_CONFIG.clone()) let mut faas = FluenceFaaS::with_raw_config(ARG_CONFIG.clone())
.unwrap_or_else(|e| panic!("can't create Fluence FaaS instance: {:?}", e)); .unwrap_or_else(|e| panic!("can't create Fluence FaaS instance: {:?}", e));
let result1 = faas.call_with_json("pure", "bool_type", json!({}), <_>::default()); let result1 = faas.call_with_json(
"arguments_passing_pure",
"bool_type",
json!({}),
<_>::default(),
);
assert!(result1.is_err()); assert!(result1.is_err());
let result2 = faas.call_with_json("pure", "bool_type", json!([]), <_>::default()); let result2 = faas.call_with_json(
"arguments_passing_pure",
"bool_type",
json!([]),
<_>::default(),
);
assert!(result2.is_err()); assert!(result2.is_err());
let result3 = faas let result3 = faas
.call_with_json("pure", "bool_type", json!({ "arg": 0 }), <_>::default()) .call_with_json(
"arguments_passing_pure",
"bool_type",
json!({ "arg": 0 }),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke bool_type: {:?}", e)); .unwrap_or_else(|e| panic!("can't invoke bool_type: {:?}", e));
assert_eq!(result3, vec![IValue::I32(1)]); assert_eq!(result3, vec![IValue::I32(1)]);
let result4 = faas let result4 = faas
.call_with_json("pure", "bool_type", json!(0), <_>::default()) .call_with_json(
"arguments_passing_pure",
"bool_type",
json!(0),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke bool_type: {:?}", e)); .unwrap_or_else(|e| panic!("can't invoke bool_type: {:?}", e));
assert_eq!(result4, vec![IValue::I32(1)]); assert_eq!(result4, vec![IValue::I32(1)]);
} }
@ -538,20 +740,40 @@ pub fn empty_type() {
.unwrap_or_else(|e| panic!("can't create Fluence FaaS instance: {:?}", e)); .unwrap_or_else(|e| panic!("can't create Fluence FaaS instance: {:?}", e));
let result1 = faas let result1 = faas
.call_with_json("pure", "empty_type", json!({}), <_>::default()) .call_with_json(
"arguments_passing_pure",
"empty_type",
json!({}),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke empty_type: {:?}", e)); .unwrap_or_else(|e| panic!("can't invoke empty_type: {:?}", e));
assert_eq!(result1, vec![IValue::String(String::from("success"))]); assert_eq!(result1, vec![IValue::String(String::from("success"))]);
let result2 = faas let result2 = faas
.call_with_json("pure", "empty_type", json!([]), <_>::default()) .call_with_json(
"arguments_passing_pure",
"empty_type",
json!([]),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke empty_type: {:?}", e)); .unwrap_or_else(|e| panic!("can't invoke empty_type: {:?}", e));
assert_eq!(result2, vec![IValue::String(String::from("success"))]); assert_eq!(result2, vec![IValue::String(String::from("success"))]);
let result3 = faas let result3 = faas
.call_with_json("pure", "empty_type", json!([]), <_>::default()) .call_with_json(
"arguments_passing_pure",
"empty_type",
json!([]),
<_>::default(),
)
.unwrap_or_else(|e| panic!("can't invoke empty_type: {:?}", e)); .unwrap_or_else(|e| panic!("can't invoke empty_type: {:?}", e));
assert_eq!(result3, vec![IValue::String(String::from("success"))]); assert_eq!(result3, vec![IValue::String(String::from("success"))]);
let result4 = faas.call_with_json("pure", "empty_type", json!([1]), <_>::default()); let result4 = faas.call_with_json(
"arguments_passing_pure",
"empty_type",
json!([1]),
<_>::default(),
);
assert!(result4.is_err()); assert!(result4.is_err());
} }

View File

@ -5,11 +5,11 @@ authors = ["Fluence Labs"]
edition = "2018" edition = "2018"
[[bin]] [[bin]]
name = "pure" name = "arguments_passing_pure"
path = "src/pure.rs" path = "src/pure.rs"
[[bin]] [[bin]]
name = "effector" name = "arguments_passing_effector"
path = "src/effector.rs" path = "src/effector.rs"
[dependencies] [dependencies]

View File

@ -1,11 +1,11 @@
modules_dir = "./artifacts/" modules_dir = "./artifacts/"
[[module]] [[module]]
name = "effector" name = "arguments_passing_effector"
mem_pages_count = 1 mem_pages_count = 1
logger_enabled = true logger_enabled = true
[[module]] [[module]]
name = "pure" name = "arguments_passing_pure"
mem_pages_count = 1 mem_pages_count = 1
logger_enabled = true logger_enabled = true

View File

@ -131,7 +131,7 @@ mod effector {
use fluence::fce; use fluence::fce;
#[fce] #[fce]
#[link(wasm_import_module = "effector")] #[link(wasm_import_module = "arguments_passing_effector")]
extern "C" { extern "C" {
pub fn all_types( pub fn all_types(
arg_0: i8, arg_0: i8,

View File

@ -0,0 +1,17 @@
[package]
name = "arrays-passing-test"
version = "0.1.0"
authors = ["Fluence Labs"]
edition = "2018"
[[bin]]
name = "arrays_passing_pure"
path = "src/pure.rs"
[[bin]]
name = "arrays_passing_effector"
path = "src/effector.rs"
[dependencies]
fluence = { git = "https://github.com/fluencelabs/rust-sdk" }
safe-transmute = "0.11.0"

View File

@ -0,0 +1,11 @@
modules_dir = "./artifacts/"
[[module]]
name = "arrays_passing_effector"
mem_pages_count = 1
logger_enabled = true
[[module]]
name = "arrays_passing_pure"
mem_pages_count = 1
logger_enabled = true

View File

@ -0,0 +1,124 @@
/*
* Copyright 2020 Fluence Labs Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
use fluence::fce;
pub fn main() {}
#[fce]
pub fn byte_type(mut arg: Vec<u8>) -> Vec<u8> {
arg.push(1);
arg
}
#[fce]
pub fn inner_arrays_1(mut arg: Vec<Vec<Vec<Vec<u8>>>>) -> Vec<Vec<Vec<Vec<u8>>>> {
arg.push(vec![]);
arg.push(vec![vec![]]);
arg.push(vec![vec![vec![]]]);
arg.push(vec![vec![vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]]);
arg
}
#[fce]
pub struct TestRecord {
pub field_0: i32,
pub field_1: Vec<Vec<u8>>,
}
#[fce]
pub fn inner_arrays_2(mut arg: Vec<Vec<Vec<Vec<TestRecord>>>>) -> Vec<Vec<Vec<Vec<TestRecord>>>> {
arg.push(vec![]);
arg.push(vec![vec![]]);
arg.push(vec![vec![vec![]]]);
arg.push(vec![vec![vec![TestRecord {
field_0: 0,
field_1: vec![vec![1, 2, 3, 4]],
}]]]);
arg
}
#[fce]
pub fn string_type(mut arg: Vec<String>) -> Vec<String> {
arg.push(String::from("from effector"));
arg
}
/*
#[fce]
pub fn bool_type(arg: Vec<bool>) -> Vec<bool> {
let mut arg = unsafe { effector::bool_type(arg) };
arg.push(false);
arg
}
*/
#[fce]
pub fn f32_type(mut arg: Vec<f32>) -> Vec<f32> {
arg.push(13.37);
arg
}
#[fce]
pub fn f64_type(mut arg: Vec<f64>) -> Vec<f64> {
arg.push(13.37);
arg
}
#[fce]
pub fn u32_type(mut arg: Vec<u32>) -> Vec<u32> {
arg.push(13);
arg.push(37);
arg
}
#[fce]
pub fn u64_type(mut arg: Vec<u64>) -> Vec<u64> {
arg.push(1);
arg.push(2);
arg.push(3);
arg.push(4);
arg
}
#[fce]
pub fn i32_type(mut arg: Vec<i32>) -> Vec<i32> {
arg.push(1);
arg.push(2);
arg.push(3);
arg.push(4);
arg.push(0);
arg
}
#[fce]
pub fn i64_type(mut arg: Vec<i64>) -> Vec<i64> {
arg.push(1);
arg.push(2);
arg.push(3);
arg.push(4);
arg.push(1);
arg
}
#[fce]
pub fn empty_type() -> Vec<String> {
vec![String::from("from effector")]
}

View File

@ -0,0 +1,152 @@
/*
* Copyright 2020 Fluence Labs Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
use fluence::fce;
pub fn main() {}
#[fce]
pub fn byte_type(arg: Vec<u8>) -> Vec<u8> {
let mut arg = unsafe { effector::byte_type(arg) };
arg.push(1);
arg
}
#[fce]
pub fn inner_arrays_1(arg: Vec<Vec<Vec<Vec<u8>>>>) -> Vec<u8> {
let mut result = unsafe { effector::inner_arrays_1(arg) };
result
}
#[fce]
pub struct TestRecord {
pub field_0: i32,
pub field_1: Vec<Vec<u8>>,
}
#[fce]
pub fn inner_arrays_2(arg: Vec<Vec<Vec<Vec<TestRecord>>>>) -> Vec<u8> {
let mut result = unsafe { effector::inner_arrays_2(arg) };
result
}
#[fce]
pub fn string_type(arg: Vec<String>) -> Vec<String> {
let mut arg = unsafe { effector::string_type(arg) };
arg.push(String::from("test"));
arg
}
/*
#[fce]
pub fn bool_type(arg: Vec<bool>) -> Vec<bool> {
let mut arg = unsafe { effector::bool_type(arg) };
arg.push(false);
arg
}
*/
#[fce]
pub fn f32_type(arg: Vec<f32>) -> Vec<f32> {
let mut arg = unsafe { effector::f32_type(arg) };
arg.push(1.0);
arg
}
#[fce]
pub fn f64_type(arg: Vec<f64>) -> Vec<f64> {
let mut arg = unsafe { effector::f64_type(arg) };
arg.push(1.0);
arg
}
#[fce]
pub fn u32_type(arg: Vec<u32>) -> Vec<u32> {
let mut arg = unsafe { effector::u32_type(arg) };
arg.push(0);
arg
}
#[fce]
pub fn u64_type(arg: Vec<u64>) -> Vec<u64> {
let mut arg = unsafe { effector::u64_type(arg) };
arg.push(0);
arg
}
#[fce]
pub fn i32_type(arg: Vec<i32>) -> Vec<i32> {
let mut arg = unsafe { effector::i32_type(arg) };
arg.push(0);
arg
}
#[fce]
pub fn i64_type(arg: Vec<i64>) -> Vec<i64> {
let mut arg = unsafe { effector::i64_type(arg) };
arg.push(1);
arg
}
#[fce]
pub fn empty_type() -> Vec<String> {
unsafe { effector::empty_type() }
}
mod effector {
use fluence::fce;
use super::TestRecord;
#[fce]
#[link(wasm_import_module = "arrays_passing_effector")]
extern "C" {
pub fn inner_arrays_1(arg: Vec<Vec<Vec<Vec<u8>>>>) -> Vec<u8>;
pub fn inner_arrays_2(arg: Vec<Vec<Vec<Vec<TestRecord>>>>) -> Vec<u8>;
pub fn string_type(arg: Vec<String>) -> Vec<String>;
pub fn byte_type(arg: Vec<u8>) -> Vec<u8>;
/*
pub fn bool_type(arg: Vec<bool>) -> Vec<bool>;
*/
pub fn f32_type(arg: Vec<f32>) -> Vec<f32>;
pub fn f64_type(arg: Vec<f64>) -> Vec<f64>;
pub fn u32_type(arg: Vec<u32>) -> Vec<u32>;
pub fn u64_type(arg: Vec<u64>) -> Vec<u64>;
pub fn i32_type(arg: Vec<i32>) -> Vec<i32>;
pub fn i64_type(arg: Vec<i64>) -> Vec<i64>;
pub fn empty_type() -> Vec<String>;
}
}

View File

@ -0,0 +1,24 @@
#!/bin/sh
# This script builds all tests
cd arguments_passing
cargo update
fce build --release
rm artifacts/*
cd ../arrays_passing
cargo update
fce build --release
rm artifacts/*
cd ../inner_records
cargo update
fce build --release
rm artifacts/*
cd ..
cp ../../../target/wasm32-wasi/release/arguments_passing_effector.wasm arguments_passing/artifacts/
cp ../../../target/wasm32-wasi/release/arguments_passing_pure.wasm arguments_passing/artifacts/
cp ../../../target/wasm32-wasi/release/arrays_passing_effector.wasm arrays_passing/artifacts/
cp ../../../target/wasm32-wasi/release/arrays_passing_pure.wasm arrays_passing/artifacts/
cp ../../../target/wasm32-wasi/release/inner_records_pure.wasm inner_records/artifacts/

View File

@ -53,7 +53,7 @@ pub fn records() {
IValue::F32(9.0), IValue::F32(9.0),
IValue::F64(10.0), IValue::F64(10.0),
IValue::String(String::from("field_11")), IValue::String(String::from("field_11")),
IValue::ByteArray(vec![0x13, 0x37]) IValue::Array(vec![IValue::U8(0x13), IValue::U8(0x37)])
]) ])
.unwrap() .unwrap()
)] )]
@ -101,7 +101,7 @@ pub fn records() {
IValue::F32(9.0), IValue::F32(9.0),
IValue::F64(10.0), IValue::F64(10.0),
IValue::String(String::from("field_11")), IValue::String(String::from("field_11")),
IValue::ByteArray(vec![0x13, 0x37]) IValue::Array(vec![IValue::U8(0x13), IValue::U8(0x37)])
]) ])
.unwrap() .unwrap()
)] )]
@ -135,7 +135,7 @@ pub fn records() {
IValue::F32(9.0), IValue::F32(9.0),
IValue::F64(10.0), IValue::F64(10.0),
IValue::String(String::from("field_11")), IValue::String(String::from("field_11")),
IValue::ByteArray(vec![0x13, 0x37]) IValue::Array(vec![IValue::U8(0x13), IValue::U8(0x37)])
]) ])
.unwrap() .unwrap()
)] )]
@ -181,7 +181,7 @@ pub fn records() {
IValue::F32(9.0), IValue::F32(9.0),
IValue::F64(10.0), IValue::F64(10.0),
IValue::String(String::from("field_11")), IValue::String(String::from("field_11")),
IValue::ByteArray(vec![0x13, 0x37]) IValue::Array(vec![IValue::U8(0x13), IValue::U8(0x37)])
]) ])
.unwrap() .unwrap()
)] )]
@ -212,7 +212,7 @@ pub fn records() {
IValue::F32(9.0), IValue::F32(9.0),
IValue::F64(10.0), IValue::F64(10.0),
IValue::String(String::from("field_11")), IValue::String(String::from("field_11")),
IValue::ByteArray(vec![0x13, 0x37]) IValue::Array(vec![IValue::U8(0x13), IValue::U8(0x37)])
]) ])
.unwrap() .unwrap()
)] )]
@ -268,7 +268,7 @@ fn inner_records() {
wasmer_wit::vec1::Vec1::new(vec![ wasmer_wit::vec1::Vec1::new(vec![
IValue::S32(1), IValue::S32(1),
IValue::String(String::new()), IValue::String(String::new()),
IValue::ByteArray(vec![1]), IValue::Array(vec![IValue::U8(1)]),
IValue::Record(wasmer_wit::vec1::Vec1::new(vec![IValue::S32(1),]).unwrap()) IValue::Record(wasmer_wit::vec1::Vec1::new(vec![IValue::S32(1),]).unwrap())
]) ])
.unwrap() .unwrap()

View File

@ -1,7 +1,7 @@
[package] [package]
name = "fcli" name = "fcli"
description = "Fluence FCE command line tool" description = "Fluence FCE command line tool"
version = "0.1.7" version = "0.1.8"
authors = ["Fluence Labs"] authors = ["Fluence Labs"]
repository = "https://github.com/fluencelabs/fce/tools/cli" repository = "https://github.com/fluencelabs/fce/tools/cli"
license = "Apache-2.0" license = "Apache-2.0"
@ -12,8 +12,8 @@ name = "fce"
path = "src/main.rs" path = "src/main.rs"
[dependencies] [dependencies]
fce-wit-generator = { path = "../../crates/wit-generator", version = "0.1.6"} fce-wit-generator = { path = "../../crates/wit-generator", version = "0.1.7"}
fce-wit-parser = { path = "../../crates/wit-parser", version = "0.1.5" } fce-wit-parser = { path = "../../crates/wit-parser", version = "0.1.6" }
anyhow = "1.0.31" anyhow = "1.0.31"
clap = "2.33.1" clap = "2.33.1"

View File

@ -1,7 +1,7 @@
[package] [package]
name = "frepl" name = "frepl"
description = "Fluence FCE REPL intended for testing purposes" description = "Fluence FCE REPL intended for testing purposes"
version = "0.1.9" version = "0.1.10"
authors = ["Fluence Labs"] authors = ["Fluence Labs"]
repository = "https://github.com/fluencelabs/fce/tools/repl" repository = "https://github.com/fluencelabs/fce/tools/repl"
license = "Apache-2.0" license = "Apache-2.0"
@ -12,7 +12,7 @@ name = "fce-repl"
path = "src/main.rs" path = "src/main.rs"
[dependencies] [dependencies]
fluence-app-service = { path = "../../fluence-app-service", version = "0.1.6", features = ["raw-module-api"] } fluence-app-service = { path = "../../fluence-app-service", version = "0.1.7", features = ["raw-module-api"] }
anyhow = "1.0.31" anyhow = "1.0.31"
clap = "2.33.1" clap = "2.33.1"