From f8a5bbdfd2dfcd67efdb9b58e90abae23397dc53 Mon Sep 17 00:00:00 2001 From: vms Date: Tue, 28 Jul 2020 17:08:26 +0300 Subject: [PATCH] introduce test-record crate in the record example --- Cargo.lock | 19 ++++++++--- Cargo.toml | 1 + examples/records/wasm/effector/Cargo.toml | 1 + examples/records/wasm/effector/src/main.rs | 18 +---------- examples/records/wasm/pure/Cargo.toml | 1 + examples/records/wasm/pure/src/main.rs | 18 +---------- examples/records/wasm/test-record/Cargo.toml | 12 +++++++ .../wasm/test-record/src/test_record.rs | 32 +++++++++++++++++++ 8 files changed, 63 insertions(+), 39 deletions(-) create mode 100644 examples/records/wasm/test-record/Cargo.toml create mode 100644 examples/records/wasm/test-record/src/test_record.rs diff --git a/Cargo.lock b/Cargo.lock index 84838785..8601835a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -318,6 +318,7 @@ name = "effector" version = "0.1.0" dependencies = [ "fluence", + "test-record", ] [[package]] @@ -441,7 +442,7 @@ dependencies = [ [[package]] name = "fluence" version = "0.2.0" -source = "git+https://github.com/fluencelabs/rust-sdk#88afe8feaa6119ebeb2032281c26f6b74f2f8fd1" +source = "git+https://github.com/fluencelabs/rust-sdk#4683526e16d6db8c93ce95dda724652dc657d35f" dependencies = [ "fluence-sdk-macro", "fluence-sdk-main", @@ -466,7 +467,7 @@ dependencies = [ [[package]] name = "fluence-sdk-macro" version = "0.2.0" -source = "git+https://github.com/fluencelabs/rust-sdk#88afe8feaa6119ebeb2032281c26f6b74f2f8fd1" +source = "git+https://github.com/fluencelabs/rust-sdk#4683526e16d6db8c93ce95dda724652dc657d35f" dependencies = [ "fluence-sdk-wit", ] @@ -474,7 +475,7 @@ dependencies = [ [[package]] name = "fluence-sdk-main" version = "0.2.0" -source = "git+https://github.com/fluencelabs/rust-sdk#88afe8feaa6119ebeb2032281c26f6b74f2f8fd1" +source = "git+https://github.com/fluencelabs/rust-sdk#4683526e16d6db8c93ce95dda724652dc657d35f" dependencies = [ "log", ] @@ -482,7 +483,7 @@ dependencies = [ [[package]] name = "fluence-sdk-wit" version = "0.2.0" -source = "git+https://github.com/fluencelabs/rust-sdk#88afe8feaa6119ebeb2032281c26f6b74f2f8fd1" +source = "git+https://github.com/fluencelabs/rust-sdk#4683526e16d6db8c93ce95dda724652dc657d35f" dependencies = [ "proc-macro2", "quote", @@ -874,6 +875,7 @@ name = "pure" version = "0.1.0" dependencies = [ "fluence", + "test-record", ] [[package]] @@ -1173,6 +1175,13 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "test-record" +version = "0.1.0" +dependencies = [ + "fluence", +] + [[package]] name = "textwrap" version = "0.11.0" @@ -1414,7 +1423,7 @@ dependencies = [ [[package]] name = "wasmer-interface-types" version = "0.17.0" -source = "git+https://github.com/fluencelabs/interface-types?branch=struct_support#eb3dbcb8353f658040621e179251b182695f04f4" +source = "git+https://github.com/fluencelabs/interface-types?branch=struct_support#33ce6228c8ad668bdae6487c6df44c6b09763454" dependencies = [ "nom", "safe-transmute", diff --git a/Cargo.toml b/Cargo.toml index 560fbdd5..572dd401 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ members = [ "examples/records", "examples/records/wasm/effector", "examples/records/wasm/pure", + "examples/records/wasm/test-record", "fluence-faas", "tools/cli", ] diff --git a/examples/records/wasm/effector/Cargo.toml b/examples/records/wasm/effector/Cargo.toml index 49b7de64..39b2cdc6 100644 --- a/examples/records/wasm/effector/Cargo.toml +++ b/examples/records/wasm/effector/Cargo.toml @@ -10,3 +10,4 @@ path = "src/main.rs" [dependencies] fluence = { git = "https://github.com/fluencelabs/rust-sdk" } +test-record = { path = "../test-record" } \ No newline at end of file diff --git a/examples/records/wasm/effector/src/main.rs b/examples/records/wasm/effector/src/main.rs index 66bb3acf..3361ddb6 100644 --- a/examples/records/wasm/effector/src/main.rs +++ b/examples/records/wasm/effector/src/main.rs @@ -15,26 +15,10 @@ */ use fluence::fce; +use test_record::TestRecord; pub fn main() {} -#[fce] -pub struct TestRecord { - pub field_0: bool, - pub field_1: i8, - pub field_2: i16, - pub field_3: i32, - pub field_4: i64, - pub field_5: u8, - pub field_6: u16, - pub field_7: u32, - pub field_8: u64, - pub field_9: f32, - pub field_10: f64, - pub field_11: String, - pub field_12: Vec, -} - #[fce] pub fn mutate_struct(mut test_record: TestRecord) -> TestRecord { test_record.field_0 = true; diff --git a/examples/records/wasm/pure/Cargo.toml b/examples/records/wasm/pure/Cargo.toml index 82a086d0..102c9485 100644 --- a/examples/records/wasm/pure/Cargo.toml +++ b/examples/records/wasm/pure/Cargo.toml @@ -10,3 +10,4 @@ path = "src/main.rs" [dependencies] fluence = { git = "https://github.com/fluencelabs/rust-sdk" } +test-record = { path = "../test-record" } diff --git a/examples/records/wasm/pure/src/main.rs b/examples/records/wasm/pure/src/main.rs index cbfa18eb..cbcae8b3 100644 --- a/examples/records/wasm/pure/src/main.rs +++ b/examples/records/wasm/pure/src/main.rs @@ -15,26 +15,10 @@ */ use fluence::fce; +use test_record::TestRecord; pub fn main() {} -#[fce] -pub struct TestRecord { - pub field_0: bool, - pub field_1: i8, - pub field_2: i16, - pub field_3: i32, - pub field_4: i64, - pub field_5: u8, - pub field_6: u16, - pub field_7: u32, - pub field_8: u64, - pub field_9: f32, - pub field_10: f64, - pub field_11: String, - pub field_12: Vec, -} - #[fce] pub fn invoke() -> TestRecord { let test_record = TestRecord { diff --git a/examples/records/wasm/test-record/Cargo.toml b/examples/records/wasm/test-record/Cargo.toml new file mode 100644 index 00000000..d0b5087c --- /dev/null +++ b/examples/records/wasm/test-record/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "test-record" +version = "0.1.0" +authors = ["Fluence Labs"] +edition = "2018" + +[lib] +name = "test_record" +path = "src/test_record.rs" + +[dependencies] +fluence = { git = "https://github.com/fluencelabs/rust-sdk" } diff --git a/examples/records/wasm/test-record/src/test_record.rs b/examples/records/wasm/test-record/src/test_record.rs new file mode 100644 index 00000000..d604149b --- /dev/null +++ b/examples/records/wasm/test-record/src/test_record.rs @@ -0,0 +1,32 @@ +/* + * Copyright 2020 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#[fluence::fce] +pub struct TestRecord { + pub field_0: bool, + pub field_1: i8, + pub field_2: i16, + pub field_3: i32, + pub field_4: i64, + pub field_5: u8, + pub field_6: u16, + pub field_7: u32, + pub field_8: u64, + pub field_9: f32, + pub field_10: f64, + pub field_11: String, + pub field_12: Vec, +}