mirror of
https://github.com/fluencelabs/examples
synced 2025-04-25 02:32:16 +00:00
merge upstream
This commit is contained in:
commit
55e25df7bb
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,7 +1,12 @@
|
|||||||
|
target
|
||||||
|
node_modules
|
||||||
|
.idea
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
.vscode
|
||||||
.repl_history
|
.repl_history
|
||||||
/target
|
/target
|
||||||
**/**.bak
|
**/**.bak
|
||||||
**/**.bk
|
**/**.bk
|
||||||
/artifacts
|
/artifacts
|
||||||
keypair.json
|
keypair.json
|
||||||
|
*.wasm
|
||||||
|
7
url-downloader/artifacts/curl_adapter.json
Normal file
7
url-downloader/artifacts/curl_adapter.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"name": "curl_adapter",
|
||||||
|
"mountedBinaries":
|
||||||
|
{
|
||||||
|
"curl": "/usr/bin/curl"
|
||||||
|
}
|
||||||
|
}
|
1
url-downloader/artifacts/facade.json
Normal file
1
url-downloader/artifacts/facade.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"name": "facade"}
|
1
url-downloader/artifacts/local_storage.json
Normal file
1
url-downloader/artifacts/local_storage.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"name": "local_storage"}
|
@ -1,18 +1,24 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh -euo pipefail
|
||||||
|
|
||||||
# This script builds all subprojects and puts all created Wasm modules in one dir
|
# This script builds all subprojects and puts all created Wasm modules in one dir
|
||||||
cd local_storage
|
(
|
||||||
cargo update
|
cd local_storage
|
||||||
fce build --release
|
cargo update
|
||||||
cd ../curl_adapter
|
fce build --release
|
||||||
cargo update
|
)
|
||||||
fce build --release
|
(
|
||||||
cd ../facade
|
cd curl_adapter
|
||||||
cargo update
|
cargo update
|
||||||
fce build --release
|
fce build --release
|
||||||
|
)
|
||||||
|
(
|
||||||
|
cd facade
|
||||||
|
cargo update
|
||||||
|
fce build --release
|
||||||
|
)
|
||||||
|
|
||||||
cd ..
|
mkdir -p artifacts
|
||||||
rm -f artifacts/*
|
rm -f artifacts/*.wasm
|
||||||
cp ../../target/wasm32-wasi/release/local_storage.wasm artifacts/
|
cp local_storage/target/wasm32-wasi/release/local_storage.wasm artifacts/
|
||||||
cp ../../target/wasm32-wasi/release/curl_adapter.wasm artifacts/
|
cp curl_adapter/target/wasm32-wasi/release/curl_adapter.wasm artifacts/
|
||||||
cp ../../target/wasm32-wasi/release/facade.wasm artifacts/
|
cp facade/target/wasm32-wasi/release/facade.wasm artifacts/
|
||||||
|
178
url-downloader/curl_adapter/Cargo.lock
generated
Normal file
178
url-downloader/curl_adapter/Cargo.lock
generated
Normal file
@ -0,0 +1,178 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
[[package]]
|
||||||
|
name = "cfg-if"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "curl_adapter"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"fluence",
|
||||||
|
"log",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fluence"
|
||||||
|
version = "0.3.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "84c621ecf5ba628a3a66c4571cb63b9e57de5b8e1ffbb4636873349d04ed9c4c"
|
||||||
|
dependencies = [
|
||||||
|
"fluence-sdk-macro",
|
||||||
|
"fluence-sdk-main",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fluence-sdk-macro"
|
||||||
|
version = "0.3.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d3ed152de2a9f59c5494a5ead9d85b40cc1588696d10bb69129addebf0239efb"
|
||||||
|
dependencies = [
|
||||||
|
"fluence-sdk-wit",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fluence-sdk-main"
|
||||||
|
version = "0.3.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5ed74c32aded592c2a4c2d11a4586369e2d9f793e6c7b500a2a22f4a61769784"
|
||||||
|
dependencies = [
|
||||||
|
"fluence-sdk-macro",
|
||||||
|
"log",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fluence-sdk-wit"
|
||||||
|
version = "0.3.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a65bb11a2ebb063b8809e43c1837d32e44c12ba3c281e55f2fcf5c5819a6a9ad"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"syn",
|
||||||
|
"uuid",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "getrandom"
|
||||||
|
version = "0.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"libc",
|
||||||
|
"wasi",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "itoa"
|
||||||
|
version = "0.4.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libc"
|
||||||
|
version = "0.2.86"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b7282d924be3275cec7f6756ff4121987bc6481325397dde6ba3e7802b1a8b1c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "log"
|
||||||
|
version = "0.4.14"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro2"
|
||||||
|
version = "1.0.24"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-xid",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "quote"
|
||||||
|
version = "1.0.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ryu"
|
||||||
|
version = "1.0.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde"
|
||||||
|
version = "1.0.118"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800"
|
||||||
|
dependencies = [
|
||||||
|
"serde_derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_derive"
|
||||||
|
version = "1.0.118"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c84d3526699cd55261af4b941e4e725444df67aa4f9e6a3564f18030d12672df"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_json"
|
||||||
|
version = "1.0.63"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "43535db9747a4ba938c0ce0a98cc631a46ebf943c9e1d604e091df6007620bf6"
|
||||||
|
dependencies = [
|
||||||
|
"itoa",
|
||||||
|
"ryu",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syn"
|
||||||
|
version = "1.0.60"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"unicode-xid",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-xid"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "uuid"
|
||||||
|
version = "0.8.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7"
|
||||||
|
dependencies = [
|
||||||
|
"getrandom",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasi"
|
||||||
|
version = "0.10.2+wasi-snapshot-preview1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
|
@ -10,5 +10,5 @@ path = "src/main.rs"
|
|||||||
name = "curl_adapter"
|
name = "curl_adapter"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
fluence = { version = "=0.3.2", features = ["logger"] }
|
fluence = { version = "=0.3.3", features = ["logger"] }
|
||||||
log = "0.4.8"
|
log = "0.4.8"
|
||||||
|
@ -19,7 +19,8 @@
|
|||||||
use fluence::fce;
|
use fluence::fce;
|
||||||
|
|
||||||
use fluence::WasmLoggerBuilder;
|
use fluence::WasmLoggerBuilder;
|
||||||
use fluence::MountedBinaryResult;
|
use fluence::MountedBinaryResult as Result;
|
||||||
|
use fluence::MountedBinaryStringResult as StringResult;
|
||||||
|
|
||||||
/// Log level can be changed by `RUST_LOG` env as well.
|
/// Log level can be changed by `RUST_LOG` env as well.
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
@ -27,16 +28,21 @@ pub fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[fce]
|
#[fce]
|
||||||
pub fn download(url: String) -> String {
|
pub fn request(url: String) -> StringResult {
|
||||||
log::info!("get called with url {}", url);
|
unsafe { curl(vec![url]) }.stringify().unwrap()
|
||||||
|
|
||||||
let result = unsafe { curl(vec![url]) };
|
|
||||||
String::from_utf8(result.stdout).unwrap()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[fce]
|
||||||
|
pub fn download(url: String) -> Result {
|
||||||
|
log::info!("download called with url {}", url);
|
||||||
|
|
||||||
|
unsafe { curl(vec![url]) }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Permissions in `Config.toml` should exist to use host functions.
|
/// Permissions in `Config.toml` should exist to use host functions.
|
||||||
#[fce]
|
#[fce]
|
||||||
#[link(wasm_import_module = "host")]
|
#[link(wasm_import_module = "host")]
|
||||||
extern "C" {
|
extern "C" {
|
||||||
fn curl(cmd: Vec<String>) -> MountedBinaryResult;
|
fn curl(cmd: Vec<String>) -> Result;
|
||||||
}
|
}
|
||||||
|
12
url-downloader/deploy.sh
Executable file
12
url-downloader/deploy.sh
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh -euo pipefail
|
||||||
|
|
||||||
|
# build wasms
|
||||||
|
sh build.sh
|
||||||
|
|
||||||
|
(
|
||||||
|
cd artifacts
|
||||||
|
fldist new_service --name "url_downloader" --modules \
|
||||||
|
curl_adapter.wasm:curl_adapter.json \
|
||||||
|
local_storage.wasm:local_storage.json \
|
||||||
|
facade.wasm:facade.json
|
||||||
|
)
|
7
url-downloader/download.clj
Normal file
7
url-downloader/download.clj
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
(xor
|
||||||
|
(seq
|
||||||
|
(call relay (service "request") ["https://api.duckduckgo.com/?q=homotopy&format=json"] result)
|
||||||
|
(call %init_peer_id% (returnService "run") [result])
|
||||||
|
)
|
||||||
|
(call %init_peer_id% (returnService "run") [%last_error%])
|
||||||
|
)
|
185
url-downloader/facade/Cargo.lock
generated
Normal file
185
url-downloader/facade/Cargo.lock
generated
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
[[package]]
|
||||||
|
name = "base64"
|
||||||
|
version = "0.13.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg-if"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "facade"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"base64",
|
||||||
|
"fluence",
|
||||||
|
"log",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fluence"
|
||||||
|
version = "0.3.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "84c621ecf5ba628a3a66c4571cb63b9e57de5b8e1ffbb4636873349d04ed9c4c"
|
||||||
|
dependencies = [
|
||||||
|
"fluence-sdk-macro",
|
||||||
|
"fluence-sdk-main",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fluence-sdk-macro"
|
||||||
|
version = "0.3.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d3ed152de2a9f59c5494a5ead9d85b40cc1588696d10bb69129addebf0239efb"
|
||||||
|
dependencies = [
|
||||||
|
"fluence-sdk-wit",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fluence-sdk-main"
|
||||||
|
version = "0.3.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5ed74c32aded592c2a4c2d11a4586369e2d9f793e6c7b500a2a22f4a61769784"
|
||||||
|
dependencies = [
|
||||||
|
"fluence-sdk-macro",
|
||||||
|
"log",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fluence-sdk-wit"
|
||||||
|
version = "0.3.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a65bb11a2ebb063b8809e43c1837d32e44c12ba3c281e55f2fcf5c5819a6a9ad"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"syn",
|
||||||
|
"uuid",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "getrandom"
|
||||||
|
version = "0.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"libc",
|
||||||
|
"wasi",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "itoa"
|
||||||
|
version = "0.4.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libc"
|
||||||
|
version = "0.2.86"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b7282d924be3275cec7f6756ff4121987bc6481325397dde6ba3e7802b1a8b1c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "log"
|
||||||
|
version = "0.4.14"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro2"
|
||||||
|
version = "1.0.24"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-xid",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "quote"
|
||||||
|
version = "1.0.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ryu"
|
||||||
|
version = "1.0.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde"
|
||||||
|
version = "1.0.118"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800"
|
||||||
|
dependencies = [
|
||||||
|
"serde_derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_derive"
|
||||||
|
version = "1.0.118"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c84d3526699cd55261af4b941e4e725444df67aa4f9e6a3564f18030d12672df"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_json"
|
||||||
|
version = "1.0.63"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "43535db9747a4ba938c0ce0a98cc631a46ebf943c9e1d604e091df6007620bf6"
|
||||||
|
dependencies = [
|
||||||
|
"itoa",
|
||||||
|
"ryu",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syn"
|
||||||
|
version = "1.0.60"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"unicode-xid",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-xid"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "uuid"
|
||||||
|
version = "0.8.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7"
|
||||||
|
dependencies = [
|
||||||
|
"getrandom",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasi"
|
||||||
|
version = "0.10.2+wasi-snapshot-preview1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
|
@ -10,6 +10,6 @@ name = "facade"
|
|||||||
path = "src/main.rs"
|
path = "src/main.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
fluence = { version = "=0.3.2", features = ["logger"]}
|
fluence = { version = "=0.3.3", features = ["logger"]}
|
||||||
anyhow = "1.0.31"
|
|
||||||
log = "0.4.8"
|
log = "0.4.8"
|
||||||
|
base64 = "0.13.0"
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#![allow(improper_ctypes)]
|
#![allow(improper_ctypes)]
|
||||||
|
|
||||||
use fluence::fce;
|
use fluence::fce;
|
||||||
|
use fluence::MountedBinaryResult as Result;
|
||||||
use fluence::WasmLoggerBuilder;
|
use fluence::WasmLoggerBuilder;
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
@ -25,21 +26,32 @@ pub fn main() {
|
|||||||
/// Combining of modules: `curl` and `local_storage`.
|
/// Combining of modules: `curl` and `local_storage`.
|
||||||
/// Calls `curl` and stores returned result into a file.
|
/// Calls `curl` and stores returned result into a file.
|
||||||
#[fce]
|
#[fce]
|
||||||
pub fn get_n_save(url: String, file_name: String) -> String {
|
pub fn get_n_save(url: String, file_name: String) -> i32 {
|
||||||
let result = unsafe { download(url) };
|
let result = unsafe { download(url) };
|
||||||
unsafe { file_put(file_name, result.into_bytes()) };
|
if result.is_success() {
|
||||||
|
log::info!("saving file {}", file_name);
|
||||||
|
unsafe { file_put(file_name, result.stdout) };
|
||||||
|
} else {
|
||||||
|
log::error!("download failed: {:#?}", result.as_std())
|
||||||
|
}
|
||||||
|
|
||||||
String::from("Ok")
|
result.ret_code
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Importing `curl` module
|
#[fce]
|
||||||
|
pub fn load_file(file_name: String) -> String {
|
||||||
|
let bytes = unsafe { file_get(file_name) };
|
||||||
|
base64::encode(bytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Import `curl_adapter` module
|
||||||
#[fce]
|
#[fce]
|
||||||
#[link(wasm_import_module = "curl_adapter")]
|
#[link(wasm_import_module = "curl_adapter")]
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn download(url: String) -> String;
|
pub fn download(url: String) -> Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Importing `local_storage` module
|
/// Import `local_storage` module
|
||||||
#[fce]
|
#[fce]
|
||||||
#[link(wasm_import_module = "local_storage")]
|
#[link(wasm_import_module = "local_storage")]
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
178
url-downloader/local_storage/Cargo.lock
generated
Normal file
178
url-downloader/local_storage/Cargo.lock
generated
Normal file
@ -0,0 +1,178 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
[[package]]
|
||||||
|
name = "cfg-if"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fluence"
|
||||||
|
version = "0.3.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "84c621ecf5ba628a3a66c4571cb63b9e57de5b8e1ffbb4636873349d04ed9c4c"
|
||||||
|
dependencies = [
|
||||||
|
"fluence-sdk-macro",
|
||||||
|
"fluence-sdk-main",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fluence-sdk-macro"
|
||||||
|
version = "0.3.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d3ed152de2a9f59c5494a5ead9d85b40cc1588696d10bb69129addebf0239efb"
|
||||||
|
dependencies = [
|
||||||
|
"fluence-sdk-wit",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fluence-sdk-main"
|
||||||
|
version = "0.3.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5ed74c32aded592c2a4c2d11a4586369e2d9f793e6c7b500a2a22f4a61769784"
|
||||||
|
dependencies = [
|
||||||
|
"fluence-sdk-macro",
|
||||||
|
"log",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fluence-sdk-wit"
|
||||||
|
version = "0.3.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a65bb11a2ebb063b8809e43c1837d32e44c12ba3c281e55f2fcf5c5819a6a9ad"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"syn",
|
||||||
|
"uuid",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "getrandom"
|
||||||
|
version = "0.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"libc",
|
||||||
|
"wasi",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "itoa"
|
||||||
|
version = "0.4.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libc"
|
||||||
|
version = "0.2.86"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b7282d924be3275cec7f6756ff4121987bc6481325397dde6ba3e7802b1a8b1c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "local_storage"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"fluence",
|
||||||
|
"log",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "log"
|
||||||
|
version = "0.4.14"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro2"
|
||||||
|
version = "1.0.24"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-xid",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "quote"
|
||||||
|
version = "1.0.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ryu"
|
||||||
|
version = "1.0.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde"
|
||||||
|
version = "1.0.118"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800"
|
||||||
|
dependencies = [
|
||||||
|
"serde_derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_derive"
|
||||||
|
version = "1.0.118"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c84d3526699cd55261af4b941e4e725444df67aa4f9e6a3564f18030d12672df"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_json"
|
||||||
|
version = "1.0.63"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "43535db9747a4ba938c0ce0a98cc631a46ebf943c9e1d604e091df6007620bf6"
|
||||||
|
dependencies = [
|
||||||
|
"itoa",
|
||||||
|
"ryu",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syn"
|
||||||
|
version = "1.0.60"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"unicode-xid",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-xid"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "uuid"
|
||||||
|
version = "0.8.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7"
|
||||||
|
dependencies = [
|
||||||
|
"getrandom",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasi"
|
||||||
|
version = "0.10.2+wasi-snapshot-preview1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
|
@ -10,5 +10,5 @@ name = "local_storage"
|
|||||||
path = "src/main.rs"
|
path = "src/main.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
fluence = { version = "=0.3.2", features = ["logger"]}
|
fluence = { version = "=0.3.3", features = ["logger"]}
|
||||||
log = "0.4.8"
|
log = "0.4.8"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user