update to marine 0.6.2, remove unsafe

This commit is contained in:
boneyard93501
2021-04-30 02:57:54 -05:00
parent 9552aaab92
commit 3d267b0906
9 changed files with 325 additions and 85 deletions

View File

@ -1,5 +1,11 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "autocfg"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
[[package]]
name = "cfg-if"
version = "1.0.0"
@ -7,29 +13,54 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "fluence"
version = "0.5.0"
name = "chrono"
version = "0.4.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "342831732a977f13220ecd6f25c7e6b6127af8d3794d42e3c880b05e457a0484"
checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73"
dependencies = [
"libc",
"num-integer",
"num-traits",
"time",
"winapi",
]
[[package]]
name = "fce-timestamp-macro"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c59a6302902583b2c84e87de9d72b949da4396a369baf0aaa49e97021600bb0"
dependencies = [
"chrono",
"quote",
]
[[package]]
name = "fluence"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b731bd4a69a3945186f2ff96ff753908939c8a2debd60e1f0e8edb6a28757f8"
dependencies = [
"fce-timestamp-macro",
"fluence-sdk-macro",
"fluence-sdk-main",
"serde",
]
[[package]]
name = "fluence-sdk-macro"
version = "0.5.0"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00c840552e5e58b62d4a272e3e4aabd548e1a4519df629a51d42157c7ecbe653"
checksum = "cb43d2f51f1becb70e2125ef8ca9759597900f95cc22ce7dca981a7d6ccd7dde"
dependencies = [
"fluence-sdk-wit",
]
[[package]]
name = "fluence-sdk-main"
version = "0.5.0"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f1d126f05a798c8f812fbe47a42145478ce8029e00411b04d1c5194ab368313"
checksum = "a78910d85e3cdcb9c2baf56144f20a99925c67ac445d4156220c005bfd2f9604"
dependencies = [
"fluence-sdk-macro",
"log",
@ -38,9 +69,9 @@ dependencies = [
[[package]]
name = "fluence-sdk-wit"
version = "0.5.0"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ac71e8d48a8e2bdaccf59572dc7a8e8a1ad0de512fc452107756e37ac0bf752"
checksum = "eab3ed39703b72e0e52bce9e1760746c73f65a5694c8da4dec751d3bfdec15b8"
dependencies = [
"proc-macro2",
"quote",
@ -90,6 +121,25 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "num-integer"
version = "0.1.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db"
dependencies = [
"autocfg",
"num-traits",
]
[[package]]
name = "num-traits"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290"
dependencies = [
"autocfg",
]
[[package]]
name = "proc-macro2"
version = "1.0.24"
@ -156,6 +206,17 @@ dependencies = [
"unicode-xid",
]
[[package]]
name = "time"
version = "0.1.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255"
dependencies = [
"libc",
"wasi",
"winapi",
]
[[package]]
name = "unicode-xid"
version = "0.2.1"
@ -173,6 +234,28 @@ dependencies = [
[[package]]
name = "wasi"
version = "0.10.2+wasi-snapshot-preview1"
version = "0.10.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"

View File

@ -10,5 +10,5 @@ name = "local_storage"
path = "src/main.rs"
[dependencies]
fluence = { version = "=0.5.0", features = ["logger"]}
fluence = { version = "=0.6.2", features = ["logger"]}
log = "0.4.8"

View File

@ -1,5 +1,5 @@
/*
* Copyright 2020 Fluence Labs Limited
* Copyright 2021 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.
@ -14,10 +14,14 @@
* limitations under the License.
*/
use std::fs;
use fluence::fce;
use fluence::module_manifest;
use fluence::WasmLoggerBuilder;
use std::path::Path;
use std::fs;
use std::path::PathBuf;
module_manifest!();
const SITES_DIR: &str = "/sites/";
@ -28,14 +32,13 @@ pub fn main() {
/// You can read or write files from the file system if there is permission to use directories described in `Config.toml`.
#[fce]
pub fn put(file_name: String, file_content: Vec<u8>) -> String {
log::info!("put called with file name {}", file_name);
pub fn put(name: String, file_content: Vec<u8>) -> String {
log::info!("put called with file name {}\n", name);
let rpc_tmp_filepath = format!("{}{}", SITES_DIR, name);
let path = Path::new(SITES_DIR).join(file_name);
let result = fs::write(&path, file_content);
let result = fs::write(PathBuf::from(rpc_tmp_filepath.clone()), file_content);
if let Err(e) = result {
return format!("file {} can't be written: {}", path.to_string_lossy(), e);
return format!("file can't be written: {}", e);
}
String::from("Ok")
@ -43,9 +46,9 @@ pub fn put(file_name: String, file_content: Vec<u8>) -> String {
#[fce]
pub fn get(file_name: String) -> Vec<u8> {
log::info!("get called with file name: {}", file_name);
log::info!("get called with file name: {}\n", file_name);
let path = Path::new(SITES_DIR).join(file_name);
let tmp_filepath = format!("{}{}", SITES_DIR, file_name);
fs::read(&path).unwrap_or_else(|err| format!("error while reading file {}: {}", path.to_string_lossy(), err).into_bytes())
fs::read(tmp_filepath).unwrap_or_else(|_| b"error while reading file".to_vec())
}