mirror of
https://github.com/fluencelabs/examples
synced 2025-04-25 02:32:16 +00:00
31 lines
689 B
Rust
31 lines
689 B
Rust
#![allow(improper_ctypes)]
|
|
|
|
use marine_rs_sdk::marine;
|
|
use marine_rs_sdk::module_manifest;
|
|
|
|
use marine_rs_sdk::MountedBinaryResult;
|
|
use marine_rs_sdk::WasmLoggerBuilder;
|
|
|
|
module_manifest!();
|
|
|
|
/// Log level can be changed by `RUST_LOG` env as well.
|
|
pub fn main() {
|
|
WasmLoggerBuilder::new().build().unwrap();
|
|
}
|
|
|
|
#[marine]
|
|
pub fn download(url: String) -> String {
|
|
log::info!("download called with url {}\n", url);
|
|
|
|
let result = curl(vec![url]);
|
|
|
|
String::from_utf8(result.stdout).unwrap()
|
|
}
|
|
|
|
/// Permissions in `Config.toml` should exist to use host functions.
|
|
#[marine]
|
|
#[link(wasm_import_module = "host")]
|
|
extern "C" {
|
|
fn curl(cmd: Vec<String>) -> MountedBinaryResult;
|
|
}
|