inihx

Crates.ioinihx
lib.rsinihx
version0.1.0
created_at2025-07-24 16:51:19.980576+00
updated_at2025-07-24 16:51:19.980576+00
descriptionINI parser and Serde (de)serializer in pure Rust. Inspired by INIH C INI parser.
homepage
repositoryhttps://github.com/YOUR_USERNAME/inihx
max_upload_size
id1766298
size25,352
John Aschenbrenner (JohnnyWiseleader)

documentation

https://docs.rs/inihx

README

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)
Commit count: 0

cargo fmt