2023-04-04 00:47:54 -05:00

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;
}