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
//! # aict
//!
//! `aict` is designed for generating auto-incrementing unique IDs of a specific type.
//!
//! It provides built-in support for integer types (`i8`, `i16`, `i32`, `i64`, `isize`, `u8`, `u16`, `u32`, `u64`, `usize`). However, you can add support for your own types by implementing the [`Aictable`] trait.
//!
//! ## Example
//!
//! ```rust
//! use aict::Factory;
//!
//! // Creates a new Factory for u32 IDs.
//! let mut factory = Factory::<u32>::builder()
//! // Sets the initial value for the IDs.
//! // For built-in types, the default value is the minimum value.
//! // .initial_value(1)
//!
//! // Whether to loop back to the initial value after reaching the maximum value.
//! // Default is false.
//! // .looping(true)
//!
//! // Whether to rewind to the position of the latest removed ID when generating the next ID.
//! // Default is false.
//! // .rewind(true)
//!
//! .build();
//!
//! // Generates some IDs.
//! assert_eq!(factory.next().unwrap(), 0);
//! assert_eq!(factory.next().unwrap(), 1);
//!
//! // Removes an ID so that it can be reused in the future.
//! factory.remove(0);
//!
//! // Manually marks an ID as used.
//! assert!(factory.take_up(2).is_ok());
//! // Since 2 was taken up, the next available ID is 3.
//! // However, if rewind is set to true, the next ID is 0.
//! assert_eq!(factory.next().unwrap(), 3);
//! ```
pub use Aictable;
pub use FactoryBuilder;
pub use Error;
pub use Factory;