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

aranya-policy-ifgen

Tools for generating Rust interfaces to Aranya Policies

1 unstable release

0.1.0 Oct 16, 2024

#530 in Asynchronous

Download history 190/week @ 2024-10-14 19/week @ 2024-10-21 21/week @ 2024-11-04 15/week @ 2024-11-11

65 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
~435K SLoC