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

macro no-std ockam_macros

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

20 breaking releases

Uses new Rust 2021

new 0.24.0 Sep 21, 2022
0.22.0 Sep 7, 2022
0.16.0 Jun 14, 2022
0.11.0 Mar 28, 2022
0.3.0 Dec 14, 2021

#583 in Cryptography

Download history 118/week @ 2022-06-06 75/week @ 2022-06-13 117/week @ 2022-06-20 38/week @ 2022-06-27 74/week @ 2022-07-04 106/week @ 2022-07-11 167/week @ 2022-07-18 133/week @ 2022-07-25 119/week @ 2022-08-01 128/week @ 2022-08-08 102/week @ 2022-08-15 116/week @ 2022-08-22 117/week @ 2022-08-29 176/week @ 2022-09-05 150/week @ 2022-09-12 135/week @ 2022-09-19

584 downloads per month
Used in 22 crates (11 directly)

Apache-2.0

54KB
1K SLoC

ockam_macros

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.

Usage

Add this to your Cargo.toml:

[dependencies]
ockam_macros = "0.24.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.

AsyncTryClone

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

#[derive(ockam::AsyncTryClone)]
pub struct MyStruct {
    a: u32,
}

Message

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

#[derive(ockam::Message, Deserialize, Serialize)]
pub struct MyStruct {
    a: u32,
}

Node

Transforms the main function into an async function that sets up a node and provides a Context to interact with it.

#[ockam::node]
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:

#[ockam::node(no_main)]
async fn main(mut ctx: ockam::Context) -> ockam::Result<()> {
    // ...
}

Tests

To write node-related tests:

#[ockam::test]
async fn main(mut ctx: ockam::Context) -> ockam::Result<()> {
    // ...
}

To write vault-related tests:

use ockam_vault::Vault;

fn new_vault() -> Vault {
    Vault::default()
}

#[ockam_macros::vault_test]
fn hkdf() {}

Develop

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.

License

This code is licensed under the terms of the Apache License 2.0.

Dependencies

~225–630KB
~15K SLoC