update fce examples

This commit is contained in:
boneyard93501
2021-03-15 18:58:49 -05:00
parent 3dd0c531ea
commit c2e4e5e4cb
35 changed files with 108 additions and 738 deletions

View File

@ -17,10 +17,12 @@
#![allow(improper_ctypes)]
use fluence::fce;
use fluence::module_manifest;
use fluence::WasmLoggerBuilder;
use fluence::MountedBinaryResult as Result;
use fluence::MountedBinaryStringResult as StringResult;
use fluence::MountedBinaryResult;
module_manifest!();
/// Log level can be changed by `RUST_LOG` env as well.
pub fn main() {
@ -28,21 +30,16 @@ pub fn main() {
}
#[fce]
pub fn request(url: String) -> StringResult {
unsafe { curl(vec![url]) }.stringify().unwrap()
pub fn download(url: String) -> String {
log::info!("get called with url {}", url);
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.
#[fce]
#[link(wasm_import_module = "host")]
extern "C" {
fn curl(cmd: Vec<String>) -> Result;
fn curl(cmd: Vec<String>) -> MountedBinaryResult;
}