GitBook: [main] 53 pages modified

This commit is contained in:
boneyard93501 2021-06-11 07:31:57 +00:00 committed by gitbook-bot
parent 0c270c551d
commit f7b0e7a703
No known key found for this signature in database
GPG Key ID: 07D2180C7B12D0FF

View File

@ -4,7 +4,7 @@ The marine-rs-sdk empowers developers to write services suitable for peer hostin
### API ### API
The procedural macros `[marine]` and `[marine_test]` are the two primary features provided by the SDK. The `[marine]` macro can be applied to a function, external block or structure. The `[marine_test]` macro, on the other hand, allows the use of the familiar `cargo test` to execute \(unit\) tests over the actual Wasm module generated from the service code. The procedural macros `[marine]` and `[marine_test]` are the two primary features provided by the SDK. The `[marine]` macro can be applied to a function, external block or structure. The `[marine_test]` macro, on the other hand, allows the use of the familiar `cargo test` to execute tests over the actual Wasm module generated from the service code.
#### Function Export #### Function Export
@ -177,23 +177,53 @@ extern "C" {
#### Call Parameters #### Call Parameters
There is a special API function `fluence::get_call_parameters()` that returns an instance of the `CallParameters` structure defined as follows: There is a special API function `fluence::get_call_parameters()` that returns an instance of the [`CallParameters`](https://github.com/fluencelabs/marine-rs-sdk/blob/master/fluence/src/call_parameters.rs#L35) structure defined as follows:
```rust ```rust
pub struct CallParameters { pub struct CallParameters {
pub call_id: String, /// Peer id of the AIR script initiator.
pub user_name: String, pub init_peer_id: String,
pub application_id: String,
/// Id of the current service.
pub service_id: String,
/// Id of the service creator.
pub service_creator_peer_id: String,
/// Id of the host which run this service.
pub host_id: String,
/// Id of the particle which execution resulted a call this service.
pub particle_id: String,
/// Security tetraplets which described origin of the arguments.
pub tetraplets: Vec<Vec<SecurityTetraplet>>,
} }
``` ```
Where CallParameters are especially useful in constructing authentication services:
* **call\_id** is the id, or nonce, of the current call to the service. This number is unique across the calls. ```text
* **user\_name** is the user name of the caller // auth.rs
* **application\_id** is the id of the application that this service belongs to use fluence::{marine, CallParameters};
use::marine;
use crate::get_connection;
pub fn is_owner() -> bool {
let meta = marine::get_call_parameters();
let caller = meta.init_peer_id;
let owner = meta.service_creator_peer_id;
caller == owner
}
#[fce]
pub fn am_i_owner() -> bool {
is_owner()
}
```
####
#### MountedBinaryResult #### MountedBinaryResult