Skip to content
This repository was archived by the owner on Jun 6, 2025. It is now read-only.

Commit 98c06f9

Browse files
committed
Update structure
1 parent b08ef29 commit 98c06f9

File tree

25 files changed

+164
-131
lines changed

25 files changed

+164
-131
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ cargo add rowid
1515
Create an ID with the following code:
1616

1717
```rust
18-
use rowid::rowid;
18+
use rowid::base::rowid;
1919

2020
let id: String = rowid();
2121
```
2222

2323
Or start a customization with the following code:
2424

2525
```rust
26-
use rowid::{RowIDWithConfig, RowIDWithConfigResult};
26+
use rowid::with_config::{RowIDWithConfig, RowIDWithConfigResult};
2727

2828
let rwc: RowIDWithConfigResult = RowIDWithConfig::new()
2929
.char_list("0123456789ABCDEFGHJKMNPQRSTVWXYZ")

__test__/src/lib.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ mod tests {
33
use std::{io, time::SystemTime};
44

55
use rowid::{
6-
decode, encode, generate, get_randomness, rowid,
7-
system_time_to_timestamp, timestamp_to_system_time, verify,
8-
GenerateResult, RowIDWithConfig, RowIDWithConfigResult, VerifyResult,
6+
base::{
7+
decode, encode, generate, get_randomness, rowid, verify,
8+
GenerateResult, RowIDError, VerifyResult,
9+
},
10+
time::{system_time_to_timestamp, timestamp_to_system_time},
11+
with_config::{RowIDWithConfig, RowIDWithConfigResult},
912
};
1013

11-
use rowid::RowIDError;
12-
1314
// system_time_to_timestamp
1415

1516
#[test]

package/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## 0.3.0 (2024-10-14)
2+
3+
### Breaking Changes
4+
5+
- Add `base` module, and move related functions into it
6+
- Add `with_config` module, and move related functions into it
7+
- Add `time` module, and move related functions into it
8+
19
## 0.2.0 (2024-10-13)
210

311
### Breaking Changes

package/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rowid"
3-
version = "0.2.0"
3+
version = "0.3.0"
44
authors = ["Alpheus Tang"]
55
edition = "2021"
66
description = """

package/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ A time-based unique ID solution.
77
Create an ID with the following code:
88

99
```rust
10-
use rowid::rowid;
10+
use rowid::base::rowid;
1111

1212
let id: String = rowid();
1313
```
1414

1515
Or start a customization with the following code:
1616

1717
```rust
18-
use rowid::{RowIDWithConfig, RowIDWithConfigResult};
18+
use rowid::with_config::{RowIDWithConfig, RowIDWithConfigResult};
1919

2020
let rwc: RowIDWithConfigResult = RowIDWithConfig::new()
2121
.char_list("0123456789ABCDEFGHJKMNPQRSTVWXYZ")

package/src/base/mod.rs

Lines changed: 0 additions & 2 deletions
This file was deleted.

package/src/functions/rowid.rs

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
use std::io;
2-
use std::time::SystemTime;
1+
pub mod with_config;
32

4-
use crate::common::configs::{CHAR_LIST, RANDOMNESS_LENGTH};
5-
use crate::functions::decode::{decode as _decode, DecodeOptions};
6-
use crate::functions::encode::{encode as _encode, EncodeOptions};
7-
use crate::functions::generate::{
8-
generate as _generate, GenerateOptions, GenerateResult,
9-
};
10-
use crate::functions::get_randomness::{
11-
get_randomness as _get_randomness, GetRandomnessOptions,
12-
};
13-
use crate::functions::rowid::{rowid as _rowid, RowIDOptions};
14-
use crate::functions::verify::{
15-
verify as _verify, VerifyOptions, VerifyResult,
3+
use std::{io, time::SystemTime};
4+
5+
use crate::internal::{
6+
common::configs::{CHAR_LIST, RANDOMNESS_LENGTH},
7+
functions::{
8+
decode::{decode as _decode, DecodeOptions},
9+
encode::{encode as _encode, EncodeOptions},
10+
generate::{generate as _generate, GenerateOptions, GenerateResult},
11+
get_randomness::{
12+
get_randomness as _get_randomness, GetRandomnessOptions,
13+
},
14+
rowid::{rowid as _rowid, RowIDOptions},
15+
verify::{verify as _verify, VerifyOptions, VerifyResult},
16+
},
1617
};
1718

1819
/// This function generates a 32-character unique ID
@@ -21,7 +22,7 @@ use crate::functions::verify::{
2122
/// ## Example
2223
///
2324
/// ```no_run
24-
/// use rowid::rowid;
25+
/// use rowid::base::rowid;
2526
///
2627
/// let id: String = rowid();
2728
/// ```
@@ -39,7 +40,7 @@ pub fn rowid() -> String {
3940
///
4041
/// ```no_run
4142
/// use std::time::SystemTime;
42-
/// use rowid::encode;
43+
/// use rowid::base::encode;
4344
///
4445
/// let encoded: String = encode(SystemTime::now()).unwrap();
4546
/// ```
@@ -53,7 +54,7 @@ pub fn encode(system_time: SystemTime) -> io::Result<String> {
5354
///
5455
/// ```no_run
5556
/// use std::time::SystemTime;
56-
/// use rowid::decode;
57+
/// use rowid::base::decode;
5758
///
5859
/// let decoded: SystemTime = decode("ABC123").unwrap();
5960
/// ```
@@ -67,7 +68,7 @@ pub fn decode(encoded: &str) -> io::Result<SystemTime> {
6768
///
6869
/// ```no_run
6970
/// use std::time::SystemTime;
70-
/// use rowid::{generate, GenerateResult};
71+
/// use rowid::base::{generate, GenerateResult};
7172
///
7273
/// let now: SystemTime = SystemTime::now();
7374
/// let result: GenerateResult = generate(now, Some(22));
@@ -91,7 +92,7 @@ pub fn generate(
9192
/// ## Example
9293
///
9394
/// ```no_run
94-
/// use rowid::{verify, VerifyResult};
95+
/// use rowid::base::{verify, VerifyResult};
9596
///
9697
/// let result: VerifyResult = verify("ABC123");
9798
/// ```
@@ -104,7 +105,7 @@ pub fn verify(encoded: &str) -> VerifyResult {
104105
/// ## Example
105106
///
106107
/// ```no_run
107-
/// use rowid::get_randomness;
108+
/// use rowid::base::get_randomness;
108109
///
109110
/// let randomness: String = get_randomness(10);
110111
/// ```
Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
use std::io;
2-
use std::time::SystemTime;
1+
use std::{io, time::SystemTime};
32

4-
use crate::common::configs::{CHAR_LIST, RANDOMNESS_LENGTH};
5-
use crate::common::errors::RowIDError;
6-
use crate::functions::decode::{decode as _decode, DecodeOptions};
7-
use crate::functions::encode::{encode as _encode, EncodeOptions};
8-
use crate::functions::generate::{
9-
generate as _generate, GenerateOptions, GenerateResult,
10-
};
11-
use crate::functions::get_randomness::{
12-
get_randomness as _get_randomness, GetRandomnessOptions,
13-
};
14-
use crate::functions::rowid::{rowid as _rowid, RowIDOptions};
15-
use crate::functions::verify::{
16-
verify as _verify, VerifyOptions, VerifyResult,
3+
use crate::internal::{
4+
common::{
5+
configs::{CHAR_LIST, RANDOMNESS_LENGTH},
6+
errors::RowIDError,
7+
},
8+
functions::{
9+
decode::{decode as _decode, DecodeOptions},
10+
encode::{encode as _encode, EncodeOptions},
11+
generate::{generate as _generate, GenerateOptions, GenerateResult},
12+
get_randomness::{
13+
get_randomness as _get_randomness, GetRandomnessOptions,
14+
},
15+
rowid::{rowid as _rowid, RowIDOptions},
16+
verify::{verify as _verify, VerifyOptions, VerifyResult},
17+
},
1718
};
1819

1920
/// This struct contains the state of the `RowIDWithConfig` struct.
@@ -31,7 +32,7 @@ pub struct RowIDWithConfigState<'a> {
3132
/// ## Example
3233
///
3334
/// ```no_run
34-
/// use rowid::{RowIDWithConfig, RowIDWithConfigResult};
35+
/// use rowid::with_config::{RowIDWithConfig, RowIDWithConfigResult};
3536
///
3637
/// let rwc: RowIDWithConfigResult =
3738
/// RowIDWithConfig::new().done().unwrap();
@@ -49,7 +50,7 @@ impl<'a> RowIDWithConfigResult<'a> {
4950
/// ## Example
5051
///
5152
/// ```no_run
52-
/// use rowid::{RowIDWithConfig, RowIDWithConfigResult};
53+
/// use rowid::with_config::{RowIDWithConfig, RowIDWithConfigResult};
5354
///
5455
/// let rwc: RowIDWithConfigResult =
5556
/// RowIDWithConfig::new().done().unwrap();
@@ -69,7 +70,7 @@ impl<'a> RowIDWithConfigResult<'a> {
6970
///
7071
/// ```no_run
7172
/// use std::time::SystemTime;
72-
/// use rowid::{RowIDWithConfig, RowIDWithConfigResult};
73+
/// use rowid::with_config::{RowIDWithConfig, RowIDWithConfigResult};
7374
///
7475
/// let rwc: RowIDWithConfigResult =
7576
/// RowIDWithConfig::new().done().unwrap();
@@ -88,7 +89,7 @@ impl<'a> RowIDWithConfigResult<'a> {
8889
///
8990
/// ```no_run
9091
/// use std::time::SystemTime;
91-
/// use rowid::{RowIDWithConfig, RowIDWithConfigResult};
92+
/// use rowid::with_config::{RowIDWithConfig, RowIDWithConfigResult};
9293
///
9394
/// let rwc: RowIDWithConfigResult =
9495
/// RowIDWithConfig::new().done().unwrap();
@@ -107,7 +108,10 @@ impl<'a> RowIDWithConfigResult<'a> {
107108
///
108109
/// ```no_run
109110
/// use std::time::SystemTime;
110-
/// use rowid::{RowIDWithConfig, RowIDWithConfigResult, GenerateResult};
111+
/// use rowid::{
112+
/// base::GenerateResult,
113+
/// with_config::{RowIDWithConfig, RowIDWithConfigResult}
114+
/// };
111115
///
112116
/// let rwc: RowIDWithConfigResult =
113117
/// RowIDWithConfig::new().done().unwrap();
@@ -134,7 +138,10 @@ impl<'a> RowIDWithConfigResult<'a> {
134138
/// ## Example
135139
///
136140
/// ```no_run
137-
/// use rowid::{RowIDWithConfig, RowIDWithConfigResult, VerifyResult};
141+
/// use rowid::{
142+
/// base::VerifyResult,
143+
/// with_config::{RowIDWithConfig, RowIDWithConfigResult}
144+
/// };
138145
///
139146
/// let rwc: RowIDWithConfigResult =
140147
/// RowIDWithConfig::new().done().unwrap();
@@ -152,7 +159,7 @@ impl<'a> RowIDWithConfigResult<'a> {
152159
/// ## Example
153160
///
154161
/// ```no_run
155-
/// use rowid::{RowIDWithConfig, RowIDWithConfigResult};
162+
/// use rowid::with_config::{RowIDWithConfig, RowIDWithConfigResult};
156163
///
157164
/// let rwc: RowIDWithConfigResult =
158165
/// RowIDWithConfig::new().done().unwrap();
@@ -177,7 +184,7 @@ impl<'a> RowIDWithConfigResult<'a> {
177184
/// ## Example
178185
///
179186
/// ```no_run
180-
/// use rowid::{RowIDWithConfig, RowIDWithConfigResult};
187+
/// use rowid::with_config::{RowIDWithConfig, RowIDWithConfigResult};
181188
///
182189
/// let rwc: RowIDWithConfigResult =
183190
/// RowIDWithConfig::new().done().unwrap();
@@ -193,7 +200,7 @@ impl<'a> RowIDWithConfig<'a> {
193200
/// ## Example
194201
///
195202
/// ```no_run
196-
/// use rowid::{RowIDWithConfig, RowIDWithConfigResult};
203+
/// use rowid::with_config::{RowIDWithConfig, RowIDWithConfigResult};
197204
///
198205
/// let rwc: RowIDWithConfigResult =
199206
/// RowIDWithConfig::new().done().unwrap();
@@ -215,7 +222,7 @@ impl<'a> RowIDWithConfig<'a> {
215222
/// ## Example
216223
///
217224
/// ```no_run
218-
/// use rowid::{RowIDWithConfig, RowIDWithConfigResult};
225+
/// use rowid::with_config::{RowIDWithConfig, RowIDWithConfigResult};
219226
///
220227
/// let rwc: RowIDWithConfigResult = RowIDWithConfig::new()
221228
/// .char_list("0123456789ABCDEFGHJKMNPQRSTVWXYZ")
@@ -241,7 +248,7 @@ impl<'a> RowIDWithConfig<'a> {
241248
/// ## Example
242249
///
243250
/// ```no_run
244-
/// use rowid::{RowIDWithConfig, RowIDWithConfigResult};
251+
/// use rowid::with_config::{RowIDWithConfig, RowIDWithConfigResult};
245252
///
246253
/// let rwc: RowIDWithConfigResult = RowIDWithConfig::new()
247254
/// .randomness_length(22)
@@ -264,7 +271,7 @@ impl<'a> RowIDWithConfig<'a> {
264271
/// ## Example
265272
///
266273
/// ```no_run
267-
/// use rowid::{RowIDWithConfig, RowIDWithConfigResult};
274+
/// use rowid::with_config::{RowIDWithConfig, RowIDWithConfigResult};
268275
///
269276
/// let rwc: RowIDWithConfigResult =
270277
/// RowIDWithConfig::new().done().unwrap();

0 commit comments

Comments
 (0)