initial version

This commit is contained in:
vms 2021-03-02 11:38:03 +03:00
parent 947d2047fb
commit cd21f80c59
6 changed files with 88 additions and 11 deletions

View File

@ -30,7 +30,8 @@ logger = ["fluence-sdk-main/logger"]
[workspace]
members = [
"crates/main",
"crates/macro",
"crates/macro-test",
"crates/main",
"crates/wit",
]

View File

@ -0,0 +1,21 @@
[package]
name = "fluence-sdk-macro-test"
version = "0.4.2" # remember to update html_root_url
edition = "2018"
description = "Definition of the `#[fce_test]` macro"
documentation = "https://docs.rs/fluence/fluence-sdk-macro"
repository = "https://github.com/fluencelabs/rust-sdk/crates/macro"
authors = ["Fluence Labs"]
keywords = ["fluence", "sdk", "webassembly", "procedural_macros"]
categories = ["api-bindings", "wasm"]
license = "Apache-2.0"
[package.metadata.docs.rs] # https://docs.rs/about
all-features = true
[lib]
proc-macro = true
[dependencies]
fluence-app-service = "0.5.2"
#fluence-sdk-wit = { path = "../wit", version = "=0.4.2" }

View File

@ -0,0 +1,16 @@
/*
* 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.
*/

View File

@ -0,0 +1,43 @@
/*
* 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.
*/
#![doc(html_root_url = "https://docs.rs/fluence-sdk-macro/0.4.2")]
#![deny(
dead_code,
nonstandard_style,
unused_imports,
unused_mut,
unused_unsafe,
unreachable_patterns
)]
#![warn(rust_2018_idioms)]
#![recursion_limit = "1024"]
mod fce_test;
use proc_macro::TokenStream;
#[proc_macro_attribute]
pub fn fce_test(attr: TokenStream, input: TokenStream) -> TokenStream {
// into converts proc_macro::TokenStream to proc_macro2::TokenStream
match fce_impl(input.into()) {
Ok(v) => v,
// converts syn:error to proc_macro2::TokenStream
Err(e) => e.to_compile_error(),
}
// converts proc_macro2::TokenStream to proc_macro::TokenStream
.into()
}

View File

@ -2,7 +2,7 @@
name = "fluence-sdk-macro"
version = "0.4.2" # remember to update html_root_url
edition = "2018"
description = "Definition of `#[invoke_handler]` attribute"
description = "Definition of the `#[fce]` macro"
documentation = "https://docs.rs/fluence/fluence-sdk-macro"
repository = "https://github.com/fluencelabs/rust-sdk/crates/macro"
authors = ["Fluence Labs"]

View File

@ -34,22 +34,18 @@
//! and how a struct could be passed:
//!
//! ```
//! #[fce]
//! struct HostReturnValue {
//! pub error_code: i32,
//! pub outcome: Vec<u8>
//! }
//! use fluence::MountedBinaryResult;
//!
//! #[fce]
//! pub fn read_ipfs_file(file_path: String) -> HostReturnValue {
//! pub fn read_ipfs_file(file_path: String) -> MountedBinaryResult {
//! let hash = calculate_hash(file_path);
//! ipfs(hash)
//! ipfs(vec![hash])
//! }
//!
//! #[fce]
//! #[link(wasm_import_module = "ipfs_node.wasm")]
//! #[link(wasm_import_module = "ipfs_node")]
//! extern "C" {
//! pub fn ipfs(file_hash: String) -> HostReturnValue;
//! pub fn ipfs(file_hash: Vec<String>) -> MountedBinaryResult;
//! }
//!
//! ```