#aranya #policy #generate #generator #policies #interface #typed

aranya-policy-ifgen

Tools for generating Rust interfaces to Aranya Policies

2 unstable releases

new 0.2.0 Dec 4, 2024
0.1.0 Oct 16, 2024

#503 in Asynchronous

Download history 170/week @ 2024-10-12 36/week @ 2024-10-19 3/week @ 2024-10-26 20/week @ 2024-11-02 15/week @ 2024-11-09 73/week @ 2024-11-16 79/week @ 2024-11-23 144/week @ 2024-11-30

316 downloads per month
Used in 2 crates (via aranya-daemon)

AGPL-3.0-only

470KB
11K SLoC

Policy Interface Generation

Generate typed Rust interface from policy code.

Quickstart

# Cargo.toml

[dependencies]
aranya-policy-ifgen = { ... }

[build-dependencies]
aranya-policy-ifgen-build = { ... }
// build.rs

fn main() {
    println!("cargo:rerun-if-changed=src/policy.md");
    aranya_policy_ifgen_build::generate("src/policy.md", "src/policy.rs").unwrap();
}
// src/lib.rs

#[rustfmt::skip]
mod policy;

impl aranya_policy_ifgen::Actor for MyActor { ... }

fn do_the_thing(actor: &MyActor) -> Result<(), aranya_runtime::ClientError> {
    use policy::ActorExt;
    actor.some_action(42, "my string")
}

Dependencies

~18–28MB
~433K SLoC