Skip to main content

Crate aranya_policy_ifgen

Crate aranya_policy_ifgen 

Source
Expand description

§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

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")
}

Modules§

macros
Macros used in code generated by `policy_ifgen_build``.

Macros§

format
Creates a String using interpolation of runtime expressions.
ident
Creates an Identifier from a string literal.
text
Creates a Text from a string literal.
vm_action
Creates a VmAction.
vm_effect
Creates a VmEffectData.

Structs§

EffectVariantMismatch
The effect did not match the expected variant.
Identifier
A textual identifier which matches [a-zA-Z][a-zA-Z0-9_]*.
KVPair
A generic key/value pair. Used for Effects and Command fields. Technically identical to a FactValue but separate to distinguish usage.
Struct
A Struct value
Text
A string-like value which is utf8 without nul bytes.
VmAction
VmPolicy’s actions.
VmEffect
VmPolicy’s effects.

Enums§

ClientError
An error returned by the runtime client.
EffectsParseError
Possible errors from policy effect parsing.
Value
All of the value types allowed in the VM
ValueConversionError
Indicates that the Value conversion has failed

Traits§

Actionable
A type which can be used as a VmAction.
TryFromValue
Trait for converting from a Value, similar to TryFrom<Value>.

Type Aliases§

BaseId
The base ID type.
FieldMap
Map of struct fields
Fields
Struct fields