1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
//! # inventory_kit
//!
//! **A powerful Rust toolkit for dynamic inventory management and integration.**
//!
//! `inventory_kit` is a flexible, composable inventory management framework for Rust. It supports availability tracking, time-slot-based reservations, and structured extensibility through traits and generic types.
//!
//! ## ✅ Features
//!
//! - 📦 Generic inventory system via `InventoryItem` trait
//! - ⏱️ Time-slot-based availability via `AvailabilitySlot`
//! - 🧠 Abstractions via `InventoryRepository` and `AtomicInventoryOps` traits
//! - 🗂️ In-memory implementation ready to use
//! - ⚠️ Typed error handling with `InventoryError`
//!
//! ---
//!
//! ## 📦 Use Case
//!
//! Ideal for applications needing availability tracking or reservations, such as:
//!
//! - Booking systems (rooms, rentals, events)
//! - Inventory-based games
//! - Product stock availability with time windows
//! - Scheduling of shared resources
//!
//! ---
//!
//! ## ✨ Quick Start
//!
//! ```rust
//! use inventory_kit::error::InventoryError;
//! use inventory_kit::in_memory::InMemoryInventoryRepository;
//! use inventory_kit::model::InventoryItem;
//! use inventory_kit::repository::InventoryRepository;
//!
//! #[derive(Debug, Clone, PartialEq, Eq, Hash)]
//! struct Product(u32);
//!
//! impl InventoryItem for Product {
//! type Id = u32;
//! fn id(&self) -> Self::Id {
//! self.0
//! }
//! }
//!
//! fn main() -> Result<(), InventoryError> {
//! let mut repo = InMemoryInventoryRepository::<Product, u32>::new();
//!
//! let start_time = 10_00;
//! let end_time = 20_00;
//!
//! let _ = repo.insert_availability(1, start_time, end_time, 5);
//! print!("repo.insert_availability 5 (available:5) \n{:#?}\n", repo);
//!
//! match repo.reserve(&1, start_time, end_time, 3) {
//! Ok(_) => println!("Reservation successful!"),
//! Err(e) => return Err(e),
//! }
//! print!("repo.reserve 3 (available: 5-3=2) \n{:#?}\n", repo);
//!
//! match repo.release(&1, start_time, end_time, 1) {
//! Ok(_) => println!("Release successful!"),
//! Err(e) => return Err(e),
//! }
//! print!("repo.release 1 (available: 2+1=3) \n{:#?}\n", repo);
//!
//! match repo.adjust(&1, start_time, end_time, 10) {
//! Ok(_) => println!("Adjust successful!"),
//! Err(e) => return Err(e),
//! }
//! print!("repo.adjust 10 (available: 10) \n{:#?}\n", repo);
//!
//! let slots = repo.get_availability(&1, 0, 20_00)?;
//! print!("slots item_id 1 \n{:#?}\n", slots);
//! for slot in slots {
//! println!(
//! "Item {} is available for {} units between hour {} and hour {}.",
//! slot.item_id, slot.available, slot.start, slot.end
//! );
//! }
//!
//! Ok(())
//! }
//! ```
//!
//! ---
//!
//! ## 📄 License
//!
//! Licensed under the [Apache-2.0 license](http://www.apache.org/licenses/LICENSE-2.0.txt)
//!
//! ---
//!
//! ## 👨 Author
//!
//! Jerry Maheswara <jerrymaheswara@gmail.com>
//!
//! ---
//!
//! ## ❤️ Built with Love in Rust
//!
//! This project is built with ❤️ using **Rust** — a systems programming language that is safe, fast, and concurrent.
//! Rust is the perfect choice for building reliable and efficient applications.
//!
//! ---
//!
//! ## 🤝 Contributing
//!
//! Pull requests, issues, and feedback are welcome!
//! If you find this crate useful, give it a ⭐ and share it with others in the Rustacean community.
//!
//! ---
/// Core types like `InventoryItem` and `AvailabilitySlot`
/// Traits for defining storage/repository behavior
/// Strongly-typed errors (`InventoryError`)
/// In-memory implementation of the inventory system
/// Utility module for helper functions and internal logic.