Struct aidl_parser::parser::Parser[][src]

pub struct Parser<ID> where
    ID: Eq + Hash + Clone + Debug
{ /* fields omitted */ }
Expand description

A parser instance which receives the individual AIDL files via Parser::add_content() or Parser::add_file(). Once all the files have been added, call Parser::parser() to trigger the validation and access the results. It is also possible to replace or remote a content with a given ID and re-trigger the parsing.

Example:

use aidl_parser::{Parser, ParseFileResult};

let mut parser = Parser::new();

// Add files via ID + content
parser.add_content(1, "<content of AIDL file #1>");
parser.add_content(2, "<content of AIDL file #2>");
parser.add_content(3, "<content of AIDL file #3>");

// Parse and get results
let results = parser.parse();

assert_eq!(results.len(), 3);
assert!(results.contains_key(&1));
assert!(results.contains_key(&2));
assert!(results.contains_key(&3));

// Add/replace/remote files
parser.add_content(2, "<updated content of AIDL file #2>");
parser.add_content(4, "<content of AIDL file #4>");
parser.add_content(5, "<content of AIDL file #5>");
parser.remove_content(1);

// Parse again and get updated results
let results = parser.parse();

assert_eq!(results.len(), 4);
assert!(results.contains_key(&2));
assert!(results.contains_key(&3));
assert!(results.contains_key(&4));
assert!(results.contains_key(&5));

Implementations

Create a new, empty parser

Add a file content and its key to the parser

Remote the file with the given key

Add a file to the parser and use its path as key

Trait Implementations

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.