Skip to main content

AAML

Struct AAML 

Source
pub struct AAML { /* private fields */ }
๐Ÿ‘ŽDeprecated since 2.0.0:

please use AAM and Pipeline instead

Expand description

The main AAML parser and configuration store.

Holds a flat key-value map, registered type definitions, command handlers, and schema definitions. All directives (@derive, @schema, etc.) are processed at parse time.

ยงExample

use aam_core::aaml::AAML;

let cfg = AAML::parse("host = localhost\nport = 8080").unwrap();
assert_eq!(cfg.find_obj("host").unwrap().as_str(), "localhost");

Implementationsยง

Sourceยง

impl AAML

Source

pub fn find_obj(&self, key: &str) -> Option<FoundValue>

Looks up key in the map. If not found as a key, performs a reverse lookup โ€” searching for an entry whose value matches key.

Source

pub fn find_key(&self, value: &str) -> Option<FoundValue>

Reverse lookup: finds the key whose value equals value.

Source

pub fn find_deep(&self, key: &str) -> Option<FoundValue>

Follows a chain of key -> value -> key lookups until a terminal value is reached or a cycle is detected.

Sourceยง

impl AAML

Source

pub fn validate_schemas_completeness(&self) -> Result<(), AamlError>

Checks every required field in every registered schema against the current map. Optional fields (declared with *) are skipped.

Source

pub fn validate_schemas_completeness_for( &self, schema_names: &[&str], ) -> Result<(), AamlError>

Checks required fields only for the named schemas. Used by @derive to validate only child-defined schemas, not inherited ones.

Source

pub fn apply_schema( &self, schema_name: &str, data: &HashMap<String, String>, ) -> Result<(), AamlError>

Validates a complete data map against the named schema.

For every required field declared in the schema the method checks:

  1. The key is present in data.
  2. The value satisfies the declared type (including nested schemas and lists).

Optional fields (declared with *) are only validated when they are present in data; their absence is not an error.

Sourceยง

impl AAML

Source

pub fn new() -> Self

Creates a new empty AAML instance with all default commands registered.

Source

pub const fn get_schemas(&self) -> &HashMap<String, SchemaDef>

Source

pub fn with_capacity(capacity: usize) -> Self

Creates a new AAML instance pre-allocated for capacity key-value entries.

Source

pub fn get_schema(&self, name: &str) -> Option<&SchemaDef>

Source

pub fn register_command<C: Command + 'static>(&mut self, command: C)

Registers a custom command handler.

Source

pub fn register_type<T: Type + 'static>(&mut self, name: String, type_def: T)

Registers a named type definition for use in schema field validation.

Source

pub fn get_type(&self, name: &str) -> Option<&dyn Type>

Returns the type handler registered under name, or None.

Source

pub fn unregister_type(&mut self, name: &str)

Removes the type registered under name.

Source

pub fn check_type(&self, type_name: &str, value: &str) -> Result<(), AamlError>

Validates value against a type registered under type_name.

ยงErrors

Returns AamlError if the type is not found or validation fails.

Source

pub fn validate_value( &self, type_name: &str, value: &str, ) -> Result<(), AamlError>

Validates value against the type registered as type_name, also resolving built-in primitive types and module paths.

ยงErrors

Returns AamlError if the type is not found or validation fails.

Source

pub fn merge_content(&mut self, content: &str) -> Result<(), AamlError>

Parses AAML content from a string, merging it into this instance.

ยงErrors

Returns AamlError if parsing fails (e.g., syntax errors, IO errors).

Source

pub fn merge_file<P: AsRef<Path>>( &mut self, file_path: P, ) -> Result<(), AamlError>

Reads a file from the disk and merges its content into this instance.

Source

pub fn parse(content: &str) -> Result<Self, AamlError>

Parses an AAML string and returns a new AAML instance.

Source

pub fn load<P: AsRef<Path>>(file_path: P) -> Result<Self, AamlError>

Loads an AAML file from the disk and returthe ns a new AAML instance.

Source

pub fn unwrap_quotes(s: &str) -> &str

Strips surrounding "โ€ฆ" or 'โ€ฆ' quotes. Returns the trimmed string unchanged if it is not quoted.

Source

pub fn import_schema( &mut self, name: &str, source: &mut Self, ) -> Result<(), AamlError>

Source

pub fn merge_map_weak( &mut self, other_map: &mut HashMap<Box<str>, Box<str>, RandomState>, )

Source

pub fn keys(&self) -> Vec<&str>

Returns all keys currently stored in the map.

Source

pub fn to_map(&self) -> HashMap<String, String>

Returns all key-value pairs as a HashMap<String, String>.

Trait Implementationsยง

Sourceยง

impl Add for AAML

Available on crate feature legacy only.
Sourceยง

type Output = AAML

The resulting type after applying the + operator.
Sourceยง

fn add(self, rhs: Self) -> Self

Performs the + operation. Read more
Sourceยง

impl AddAssign for AAML

Available on crate feature legacy only.
Sourceยง

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Sourceยง

impl Debug for AAML

Available on crate feature legacy only.
Sourceยง

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Sourceยง

impl Default for AAML

Available on crate feature legacy only.
Sourceยง

fn default() -> Self

Returns the โ€œdefault valueโ€ for a type. Read more

Auto Trait Implementationsยง

Blanket Implementationsยง

Sourceยง

impl<T> Any for T
where T: 'static + ?Sized,

Sourceยง

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Sourceยง

impl<T> ArchivePointee for T

Sourceยง

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Sourceยง

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Sourceยง

impl<T> Borrow<T> for T
where T: ?Sized,

Sourceยง

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Sourceยง

impl<T> BorrowMut<T> for T
where T: ?Sized,

Sourceยง

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Sourceยง

impl<T> From<T> for T

Sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

Sourceยง

impl<T, U> Into<U> for T
where U: From<T>,

Sourceยง

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Sourceยง

impl<T> LayoutRaw for T

Sourceยง

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Sourceยง

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Sourceยง

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Sourceยง

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Sourceยง

impl<T> Pointee for T

Sourceยง

type Metadata = ()

The metadata type for pointers and references to this type.
Sourceยง

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Sourceยง

type Error = Infallible

The type returned in the event of a conversion error.
Sourceยง

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Sourceยง

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Sourceยง

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Sourceยง

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.