Crate confindent

Source
Expand description

A simple configuration reader.

This crate tries to make it easy to add a configuration file to your project. It’s not the fastest out there, and it does make allocations, but I’ve tried my best to make it easy to use and the docs easy to read.

§The Format

It’s a kind of tree, key-value thing. Lines are key-value pairs, the value starting at the first space after the indent. You can add a child to a value by indenting it with spaces or tabs. Indent the same amount to add another child to that same value. Indent more than you did initially to add a grandchild. Don’t mix spaces and tabs. Like this!

Root this is the root
	Child I'm a child!
	Child You can have multiple children with the same keys!
		Grandchild I'm a grandchild!

§Example

use confindent::Confindent;
use std::error::Error;

let conf: Confindent = "User gennyble\n\tEmail gen@nyble.dev\n\tID 256".parse().unwrap();

let user = conf.child("User").unwrap();
let username = user.value().unwrap();
let email = user.child_value("Email").unwrap();
let id: usize = user.child_parse("ID").unwrap();

println!("User {username}: {id} Contact: {email}");

Structs§

Confindent
A parsed configuration file. This struct holds the values with no indentation.
ParseError
Our main error type.
Value
A parsed line of a configuration file.
ValueIterator
ValueIteratorMut

Enums§

ParseErrorKind
What kind of error happened? Oh, ParseErrorKind of error.
ValueParseError
Error returned when parsing a value fails