Skip to main content

Module builder

Module builder 

Source
Expand description

Fluent builder for constructing AAML configuration content programmatically.

AAMBuilder accumulates lines in memory and can either return them as a String or write them directly to a file. Useful in tests and code generators.

§High-level directive API

MethodDirective emitted
AAMBuilder::schema@schema Name { ... }
AAMBuilder::derive@derive file.aam / @derive file.aam::A::B
AAMBuilder::import@import file.aam
AAMBuilder::type_alias@type alias = type
AAMBuilder::comment# ...

§Example

use aam_core::builder::{AAMBuilder, SchemaField};

let mut b = AAMBuilder::new();
b.comment("Server configuration")
 .type_alias("port_t", "i32")
 .schema("Server", [
     SchemaField::required("host", "string"),
     SchemaField::required("port", "port_t"),
     SchemaField::optional("debug", "bool"),
 ])
 .add_line("host", "localhost")
 .add_line("port", "8080");

let content = b.build();
assert!(content.contains("@schema Server {"));
assert!(content.contains("host = localhost"));

Structs§

AAMBuilder
Accumulates AAML source lines and can flush them to a file or a String.
InlineObject
A builder for inline object literals { key = value, ... }.
SchemaField
A single field declaration inside a @schema block.

Enums§

BuiltInType
Enumeration of all built-in AAML types for use with the Builder API.

Functions§

parse_inline_to_map
Parses an inline object string { key = value, ... } into a HashMap<String, String>.