AAM (Abstract Alias Mapping)
A robust and lightweight configuration library for Rust built around the new pipeline-backed AAM API.
It parses .aam files (key = value), supports directives (@import, @derive, @schema, @type), and provides
fast query and formatting utilities.
The Origin Story: AAM was born out of necessity during the development of rustgames. I needed a configuration format that lived entirely outside the codebase, supported high-speed bidirectional search, and was optimized for extreme performance. What started as a specialized tool for game engine internals eventually evolved into a robust configuration ecosystem with schemas, imports, and AOT compilation.
Why AAM?
AAM was designed to solve the "configuration fatigue" in large-scale Rust projects. While formats like TOML are great for simple key-value pairs, they often fall short when your config grows. AAM introduces:
- Type Safety & Schemas: Define
@typealiases and@schemastructures directly in the config. No more "guessing" what a value should be. - Modular Architecture: Use
@importto split massive configs into clean, manageable modules. - AOT Performance: Optional Ahead-of-Time compilation "cooks" your
.aamfiles into a binary format for near-instant loading. - Developer-Centric: Built-in LSP support and formatting help you catch errors before you run the code.
AAM vs TOML
| Feature | AAM | TOML |
|---|---|---|
| Schema Validation | Native (@schema) |
External tools only |
| Modular Imports | Native (@import) |
Not supported |
| Type Aliasing | Native (@type) |
No |
| Performance | High (AOT/Binary) | Standard (Text parsing) |
| Extensibility | Pipeline-backed | Static |
What changed in 2.x
AAMis now the primary API.- Parsing/loading returns
Result<_, Vec<AamlError>>to preserve full diagnostics. - Query methods are now centered around
get,find,find_by,deep_search, andreverse_search. - Pipeline formatter and LSP helper methods are available directly on
AAM. AAMLremains available for backward compatibility, but is deprecated.
Features
- Simple
key = valuesyntax. - Directive support:
@import,@derive,@schema,@type. - Schema/type validation via pipeline.
- Search helpers for key lookup, reverse lookup, and predicate filtering.
- Formatter utilities (
format,format_range) and LSP assist (lsp_assist). - Optional AOT loading (
.aam.bin) for fast startup (aotfeature; enabled by default). - Fluent config generation with
AAMBuilder.
Format
You can find syntax documentation and examples at: https://aam.ininids.in.rs/
Installation
Add the crate to your Cargo.toml:
[]
= "2.0.3"
Configuration syntax (.aam)
# Comments are supported
host = "localhost"
port = 8080
@import database.aam
@import theme.aam
@type port_t = i32
@schema Service {
host: string
port: port_t
}
Usage (new AAM API)
1) Parse and load
use AAM;
use AamlError;
2) Lookups and queries
use AAM;
let cfg = AAMparse.unwrap;
// O(1) key lookup
assert_eq!;
// key-first lookup, then reverse lookup by value
let found = cfg.find;
assert_eq!;
// reverse lookup only
let keys = cfg.reverse_search;
assert_eq!;
// key pattern search
let deep = cfg.deep_search;
assert_eq!;
// custom predicate
let filtered = cfg.find_by;
assert_eq!;
3) Iteration and extraction
use AAM;
let cfg = AAMparse.unwrap;
for in cfg.iter
let keys = cfg.keys;
let map = cfg.to_map;
assert!;
assert_eq!;
4) Formatting and LSP helper
use AAM;
use ;
let cfg = AAMnew;
let src = "host=localhost\nport=8080";
let formatted = cfg.format.unwrap;
let _range = cfg
.format_range
.unwrap;
let assist = AAMlsp_assist;
assert!;
5) Builder (AAMBuilder)
use ;
let mut builder = new;
builder
.comment
.type_alias
.schema
.add_line
.add_line;
println!;
builder.to_file.unwrap;
Legacy API (AAML, deprecated)
AAML is still available for compatibility and supports methods such as:
parse,loadmerge_content,merge_filefind_obj,find_key,find_deepvalidate_value,apply_schema,validate_schemas_completeness
For migration guidance, see docs/AAML_TO_AAM_MIGRATION.md.
Bindings
Node.js / N-API
C# / .NET
Quick verification commands
API reference (high-level)
AAM
- Constructors/loaders:
new,parse,load,from_pipeline - Query:
get,find,find_by,deep_search,reverse_search - Iteration/export:
iter,keys,to_map - Introspection:
schemas,get_schema,types,get_type - Formatting/LSP:
format,format_range,lsp_assist - AOT (feature-gated):
cook,load_fast
AAMBuilder
new,with_capacityadd_line,commentschema,schema_multiline,derive,import,type_aliasto_file,build,as_string
AamlError
Typed errors used across parser, validator, and runtime paths.
Ecosystem Tooling
AAM CLI
For managing, formatting, and "cooking" your configuration files, check out the aam-cli.
Installation:
Key features:
- Cook: Convert .aam to binary .aam.bin for AOT loading.
- Format: Keep your config files clean and consistent.
- Check: Validate syntax and schema integrity from the terminal.
AAM Examples
If you need more examples, check aam-examples repository
License
See LICENSE-MIT and LICENSE-APACHE.
Full documentation
- Docs.rs: https://docs.rs/aam-rs/
- Project docs: https://aam.ininids.in.rs/