mirror of
https://github.com/fluencelabs/marine-rs-sdk-test
synced 2024-12-04 23:30:18 +00:00
add docs
This commit is contained in:
parent
4683526e16
commit
678cbc14d5
44
src/lib.rs
44
src/lib.rs
@ -14,11 +14,47 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
//! Rust backend SDK for applications on the Fluence network. This crate is just a wrapper for two
|
||||
//! other crates: `main` and `macro`. The `main` crate is used for all memory relative operations
|
||||
//! and logging, while the `macro` crate contains the invocation macro to simplify entry point
|
||||
//! functions.
|
||||
//! Rust backend SDK for applications on the Fluence network. This crate defines the procedure macro
|
||||
//! `#[fce]` that could be applied to a function, structure or extern block.
|
||||
//!
|
||||
//! Structures with `#[fce]` could be used then in function arguments and values
|
||||
//! (hereinafter they'll be called records). All fields of a record should be public and have one of the
|
||||
//! following primitive Rust types
|
||||
//! (`bool, u8, u16, u32, u64, i8, i16, i32, i64, f32, f64, String, Vec<u8>`).
|
||||
//! ```rust
|
||||
//! use fluence::fce;
|
||||
//!
|
||||
//! #[fce]
|
||||
//! struct T {
|
||||
//! field_1: i32,
|
||||
//! field_2: Vec<u8>,
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
//! Functions with `#[fce]` will be exported from this module:
|
||||
//!
|
||||
//! ```rust
|
||||
//! use fluence::fce;
|
||||
//!
|
||||
//! #[fce]
|
||||
//! pub fn get(url: String) -> String {
|
||||
//! // ...
|
||||
//! }
|
||||
//! ```
|
||||
//! At now, such functions could have arguments with primitive Rust types and record and only one
|
||||
//! return argument with such type could be used.
|
||||
//!
|
||||
//! Finally, to import other wasm modules to your project use similar code:
|
||||
//! ```rust
|
||||
//! use fluence::fce;
|
||||
//!
|
||||
//! #[fce]
|
||||
//! #[link(wasm_import_module = "wasm_curl.wasm")]
|
||||
//! extern "C" {
|
||||
//! #[link_name = "get"]
|
||||
//! pub fn curl_get(url: String) -> String;
|
||||
//! }
|
||||
//! ```
|
||||
#![doc(html_root_url = "https://docs.rs/fluence/0.2.0")]
|
||||
#![deny(
|
||||
dead_code,
|
||||
|
Loading…
Reference in New Issue
Block a user