# inihx
[](https://crates.io/crates/inihx)
[](https://docs.rs/inihx)
[](./LICENSE)
A simple, readable INI file parser and serializer for Rust, inspired by the [inih](https://github.com/benhoyt/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
```toml
[dependencies]
inihx = "0.1"
```
---
## Example: Basic Parsing
```rust
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
```rust
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`)