<h1 align="center">Lim</h1>
<p align="center"><em>A robust, generic bounding limit type for Rust.</em></p>
## Getting Started
### Installation
```bash
cargo add lim
```
### Basic Usage
```rust
use lim::{Lim, LimError};
fn main() {
// Create a value bounded between 0 and 10 (inclusive)
let mut health = Lim::new(10, 0, 10, true, true).unwrap();
// Reading the value via Deref
assert_eq!(*health, 10);
// Attempting to set an out-of-bounds value returns a structured error
let result = health.set_value(15);
assert!(matches!(result, Err(LimError::OutOfBounds { .. })));
}
```
## Documentation
- [Documentation](https://docs.rs/lim) — Complete documentation for this library.
## Features
- **Generic Bounds**: Supports any type implementing `PartialOrd`, `Clone`, and `Debug`.
- **Flexible Bounds**: Independently configure lower and upper bounds as inclusive (`>=` / `<=`) or exclusive (`>` / `<`).
- **Safe Clamping**: Offers optional automatic clamping when updating bounds, with strict mathematical protections for exclusive bounds to prevent ambiguity.
- **Strict Serde Support**: Built-in serialization and deserialization implementations that strictly enforce bound invariants during parsing.
- **Transparent Value Access**: Implements the `Deref` trait, allowing intuitive and direct access to the underlying value.
## License
This project is licensed under the [MIT License](LICENSE).