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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
//! # rs-histver
//!
//! A library for querying Rust historical release versions with local redb cache.
//!
//! ## As a CLI tool
//!
//! ```sh
//! rs-histver sync --channel stable
//! rs-histver list --limit 20
//! rs-histver search 1.75
//! ```
//!
//! ## As a library (standalone)
//!
//! ```ignore
//! use rs_histver::{HistVer, Config};
//!
//! // Default: database at <exe_dir>/data/rs-histver.redb
//! let hv = HistVer::new(Config::new())?;
//!
//! // Or: custom database path
//! let hv = HistVer::new(Config::with_db_path("/path/to/custom.redb"))?;
//! ```
//!
//! ## As a library (embedded in host project)
//!
//! When embedded in a host project (e.g. Tauri app), the database path
//! should be determined by the host's configuration, not by the executable
//! directory. Use `ConfigBuilder` or `Config::from_config_file()` to achieve this.
//!
//! ### Standalone mode (default)
//!
//! Creates a dedicated `rs-histver.redb` file in `data_dir`.
//!
//! ```ignore
//! use rs_histver::{HistVer, ConfigBuilder};
//!
//! let hv = HistVer::new(
//! ConfigBuilder::new()
//! .data_dir(app_data_dir) // creates <data_dir>/rs-histver.redb
//! .build()?
//! )?;
//! ```
//!
//! ### Shared mode (host uses redb)
//!
//! When the host project also uses redb, you can share the same database file.
//! Configure `db_file` to point to the host's redb file, and `table_prefix`
//! to avoid table name collisions.
//!
//! The host project's `config.toml`:
//!
//! ```toml
//! [paths]
//! # Supported variable substitution:
//! # $EXE_DIR — executable directory
//! # $HOME — user home directory
//! # ~/ — user home directory (shorthand)
//! data_dir = "$EXE_DIR/data"
//!
//! [rs-histver.database]
//! db_file = "myapp.redb" # shared: open host's redb file
//! table_prefix = "myapp_histver" # table names: myapp_histver_stable/beta/nightly
//!
//! [rs-histver.network]
//! timeout = 30 # optional, default: 15 (seconds)
//! max_concurrency = 5 # optional, default: 10
//! ```
//!
//! ```ignore
//! use rs_histver::{HistVer, Config};
//!
//! let hv = HistVer::new(Config::from_config_file("config.toml")?)?;
//! ```
//!
//! If `db_file` points to a non-redb file, it automatically falls back to
//! standalone mode (creates `rs-histver.redb` in the same directory).
//!
//! ### Programmatic configuration
//!
//! ```ignore
//! use rs_histver::{HistVer, ConfigBuilder};
//!
//! // Shared mode
//! let hv = HistVer::new(
//! ConfigBuilder::new()
//! .data_dir(app_data_dir)
//! .db_file("myapp.redb") // shared mode
//! .table_prefix("myapp_histver")
//! .build()?
//! )?;
//!
//! // Standalone mode
//! let hv = HistVer::new(
//! ConfigBuilder::new()
//! .data_dir(app_data_dir) // standalone mode (default)
//! .build()?
//! )?;
//! ```
//!
//! ### Priority order
//!
//! ```text
//! Programmatic override (highest) → config.toml → hardcoded defaults (lowest)
//! ```
//!
//! - `db_path()` overrides everything (complete file path, always standalone mode)
//! - `db_file()` enables shared mode, combined with `data_dir()`
//! - `data_dir()` alone → standalone mode: `<data_dir>/rs-histver.redb`
//! - `table_prefix()` / `timeout()` / `max_concurrency()` override config.toml values
//! - Missing config file or fields fall back to defaults silently
//!
//! ### Variable substitution in config.toml
//!
//! | Variable | Resolves to | Example (Windows) |
//! |----------|-------------|-------------------|
//! | `$EXE_DIR` | Executable directory | `C:\Program Files\MyApp` |
//! | `$HOME` | User home (`%USERPROFILE%` / `$HOME`) | `C:\Users\user` |
//! | `~/` | User home (same as `$HOME`) | `~/data` → `C:\Users\user\data` |
//!
//! Variable substitution only applies to paths read from config.toml.
//! Programmatic `data_dir()` / `db_path()` accept resolved `PathBuf` values.
//!
//! ## Core API
//!
//! ```ignore
//! use rs_histver::HistVer;
//!
//! // Fetch and cache releases (async)
//! let releases = hv.fetch_releases("stable", false, 30).await?;
//! hv.store_releases(&releases)?;
//!
//! // Query local cache (sync)
//! let all = hv.list_releases(None)?;
//! let results = hv.search_releases("1.75", None)?;
//! let count = hv.count_releases(None)?;
//! ```
pub
// ---- Public API re-exports ----
pub use RustRelease;
pub use ;
pub use Config;
pub use ConfigBuilder;
pub use Db;
use Result;
/// Main entry point for library usage.
///
/// Wraps `Config` and `Db`, providing a high-level API for fetching,
/// storing, and querying Rust release data.