#ockam #crypto #cryptography #network-programming #encryption

macro no-std ockam_macros

End-to-end encryption and mutual authentication for distributed applications

23 breaking releases

0.27.0 Feb 9, 2023
0.25.0 Nov 9, 2022
0.16.0 Jun 14, 2022
0.11.0 Mar 28, 2022
0.3.0 Dec 14, 2021

#29 in #ockam

Download history 70/week @ 2022-12-04 110/week @ 2022-12-11 83/week @ 2022-12-18 106/week @ 2022-12-25 39/week @ 2023-01-01 98/week @ 2023-01-08 86/week @ 2023-01-15 98/week @ 2023-01-22 215/week @ 2023-01-29 288/week @ 2023-02-05 110/week @ 2023-02-12 250/week @ 2023-02-19 632/week @ 2023-02-26 116/week @ 2023-03-05 51/week @ 2023-03-12 33/week @ 2023-03-19

835 downloads per month
Used in 24 crates (15 directly)




crate docs license discuss

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:

ockam_macros = "0.27.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.

pub struct MyStruct {
    a: u32,


Implements the Message trait as defined in ockam_core::Message.

#[derive(ockam::Message, Deserialize, Serialize)]
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.

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:

async fn main(mut ctx: ockam::Context) -> ockam::Result<()> {
    // ...


To write node-related tests:

async fn main(mut ctx: ockam::Context) -> ockam::Result<()> {
    // ...

To write vault-related tests:

use ockam_vault::Vault;

fn new_vault() -> Vault {

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.


~26K SLoC