inihx 0.1.0

INI parser and Serde (de)serializer in pure Rust. Inspired by INIH C INI parser.
Documentation
  • Coverage
  • 34.62%
    9 out of 26 items documented0 out of 10 items with examples
  • Size
  • Source code size: 24.85 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 3.73 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 33s Average build duration of successful builds.
  • all releases: 33s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • JohnnyWiseleader

inihx

Crates.io Docs.rs License: MIT OR BSD-3-Clause

A simple, readable INI file parser and serializer for Rust, inspired by the inih C library.


Features

  • ✅ Read and write INI files
  • ✅ Serde deserialization support (HashMap or strongly typed structs)
  • ✅ Minimal dependencies
  • ✅ Clean error reporting
  • ✅ Inspired by the simplicity of the original INIH C parser

Installation

[dependencies]
inihx = "0.1"

Example: Basic Parsing

use inihx::parse_ini_file;

fn main() -> Result<(), std::io::Error> {
    let config = parse_ini_file("config.ini")?;
    println!("{}", config["server"]["port"]);
    Ok(())
}

Example: With Serde

use inihx::de::from_ini_file;
use inihx::parse_ini::IniParserConfig;
use serde::Deserialize;

#[derive(Debug, Deserialize)]
struct Config {
    server: ServerSection,
    database: DatabaseSection,
}

#[derive(Debug, Deserialize)]
struct ServerSection {
    port: u16,
}

#[derive(Debug, Deserialize)]
struct DatabaseSection {
    user: String,
    password: String,
}

fn main() -> Result<(), std::io::Error> {
    let cfg = IniParserConfig::default();
    let parsed: Config = from_ini_file("config.ini", &cfg)?;
    println!("Port: {}", parsed.server.port);
    Ok(())
}

Embedded-Friendly (Linux-class)

While not no_std, inihx is lightweight and efficient enough for use in embedded Linux environments such as:

  • Raspberry Pi
  • OpenWRT / Buildroot
  • Yocto-based custom boards

It avoids unnecessary dependencies and is suitable for memory-constrained systems that use std.


License

Licensed under either of:

  • MIT (see LICENSE)
  • BSD-3-Clause (see LICENSE-BSD)