Installation
Basic usage
Loader
The loader pattern enables dynamic decision loading from any storage backend. Implement theZenDecisionLoaderCallback interface with a Task<JsonBuffer?> Load(string key) method. Use ConcurrentDictionary to cache decisions for optimal performance.
File system
AWS S3
Azure Blob Storage
Google Cloud Storage
Async evaluation
Evaluation methods returnTask for native async/await integration:
Error handling
Tracing
Enable tracing to inspect decision execution:Expression utilities
Evaluate ZEN expressions outside of a decision context:Custom nodes
Extend the engine with custom logic by implementingZenCustomNodeCallback:
Performance note
The C# bindings use UniFFI with P/Invoke for interoperability with the native Rust engine. This introduces some overhead compared to native Rust. Native libraries are bundled for Windows (x64), macOS (x64/ARM), and Linux (x64/ARM).
Best practices
Useusing for resource management. ZenEngine, ZenDecision, and ZenExpression implement IDisposable to release native resources.
ZenEngine instance at application startup and reuse it for all evaluations.
Implement a loader for dynamic decisions. The loader pattern centralizes decision loading logic and enables caching with ConcurrentDictionary.
Use Task.WhenAll for parallel evaluation. Evaluate multiple decisions concurrently with async/await.