Ockam is a library for building devices that communicate securely, privately and trustfully with cloud services and other devices.
This crate provides shared macros.
Add this to your Cargo.toml
:
[dependencies]
ockam_macros = "0.26.0"
All macros except for those used exclusively for testing purposes are re-exported by the ockam
crate, so you may see examples where the macros are exported from ockam_macros
if are related to tests or from ockam
in any other case.
You can read more about how to use the macros and the supported attributes by each of them in the crate documentation.
Implements the AsyncTryClone
trait as defined in ockam_core::AsyncTryClone
.
```rust
pub struct MyStruct { a: u32, } ```
Implements the Message
trait as defined in ockam_core::Message
.
```rust
pub struct MyStruct { a: u32, } ```
Transforms the main
function into an async function that sets up a node and provides a Context
to interact with it.
```rust
async fn main(mut ctx: ockam::Context) -> ockam::Result<()> { // ... } ```
If you are executing your code in a no_std
platform that doesn't support a main
entry point, you must use the no_main
attribute:
```rust
async fn main(mut ctx: ockam::Context) -> ockam::Result<()> { // ... } ```
To write node-related tests:
```rust
async fn main(mut ctx: ockam::Context) -> ockam::Result<()> { // ... } ```
To write vault-related tests:
```rust use ockam_vault::Vault;
fn new_vault() -> Vault { Vault::default() }
fn hkdf() {} ```
Due to dependencies constraints, the tests for all the macros contained in this crate are located in the ockam
crate.
To test changes done in any of the macros you can use the macro_expand_playground
from the ockam
crate to see how a macro expands
a given input.
This code is licensed under the terms of the Apache License 2.0.