Crate yini_rs

Source
Expand description

§YINI-RS

A Rust implementation of the YINI (YAML-like INI) format parser and writer.

YINI is a configuration file format that combines the simplicity of INI files with some features from YAML, including:

  • Nested sections using caret (^) notation
  • Multiple data types (strings, integers, floats, booleans, arrays)
  • Comments (both line and block comments)
  • Type coercion and conversion

§Example

use yini_rs::Parser;

let mut parser = Parser::new();
parser.parse_string(r#"
name = 'My App'
version = 1.0
debug = true
 
^ database
host = 'localhost'
port = 5432
"#)?;

// Access values
assert_eq!(parser.root()["name"].as_string()?, "My App");
assert_eq!(parser.root()["version"].as_double()?, 1.0);
assert_eq!(parser.root().get_section("database")?["port"].as_int()?, 5432);

Re-exports§

pub use error::Error;
pub use error::Result;
pub use error::ParseError;
pub use error::FileError;
pub use value::Value;
pub use section::Section;
pub use parser::Parser;

Modules§

error
Error types for the YINI parser.
parser
YINI parser and writer implementation.
section
Section structure for organizing YINI data hierarchically.
value
Value types that can be stored in YINI files.