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
//! Index module for package database queries and management.
//!
//! This module provides functionality for querying and managing package database information:
//!
//! - **Installed Package Queries** - Query installed packages using `pacman -Q*` commands
//! - **Explicit Package Tracking** - Track explicitly installed packages with different modes
//! - **Official Repository Queries** - Search and query official Arch Linux repositories
//! - **Index Fetching** - Fetch official package index from pacman or Arch Packages API
//!
//! # Features
//!
//! This module requires the `index` feature flag to be enabled:
//!
//! ```toml
//! [dependencies]
//! arch-toolkit = { version = "0.2", features = ["index"] }
//! ```
//!
//! For fuzzy search functionality, enable the `fuzzy-search` feature:
//!
//! ```toml
//! [dependencies]
//! arch-toolkit = { version = "0.2", features = ["index", "fuzzy-search"] }
//! ```
//!
//! For API fallback when pacman is unavailable, enable the `aur` feature:
//!
//! ```toml
//! [dependencies]
//! arch-toolkit = { version = "0.2", features = ["index", "aur"] }
//! ```
//!
//! # Examples
//!
//! ## Query Installed Packages
//!
//! ```no_run
//! use arch_toolkit::index::{get_installed_packages, is_installed};
//! use std::collections::HashSet;
//!
//! // Direct query without caching
//! let packages = get_installed_packages().unwrap();
//! println!("Found {} installed packages", packages.len());
//!
//! // Check if a package is installed
//! if is_installed("vim", Some(&packages)) {
//! println!("vim is installed");
//! }
//! ```
//!
//! ## Use Cache for Multiple Queries
//!
//! ```no_run
//! use arch_toolkit::index::{refresh_installed_cache, is_installed};
//! use std::collections::HashSet;
//!
//! let mut cache = HashSet::new();
//! refresh_installed_cache(Some(&mut cache)).unwrap();
//!
//! // Now use cache for fast lookups
//! for package in ["vim", "git", "python"] {
//! if is_installed(package, Some(&cache)) {
//! println!("{} is installed", package);
//! }
//! }
//! ```
//!
//! ## Async Cache Refresh
//!
//! ```no_run
//! use arch_toolkit::index::refresh_installed_cache_async;
//! use std::collections::HashSet;
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! let mut cache = HashSet::new();
//! let packages = refresh_installed_cache_async(Some(&mut cache)).await?;
//! println!("Refreshed cache with {} packages", packages.len());
//! # Ok(())
//! # }
//! ```
//!
//! ## Query Explicit Packages
//!
//! ```no_run
//! use arch_toolkit::index::{refresh_explicit_cache, is_explicit, InstalledPackagesMode};
//! use std::collections::HashSet;
//!
//! let mut cache = HashSet::new();
//! // Get all explicitly installed packages
//! refresh_explicit_cache(InstalledPackagesMode::AllExplicit, Some(&mut cache)).unwrap();
//!
//! // Check if a package is explicitly installed
//! if is_explicit("vim", InstalledPackagesMode::AllExplicit, Some(&cache)) {
//! println!("vim is explicitly installed");
//! }
//!
//! // Get only leaf packages (not required by others)
//! let leaf_packages = refresh_explicit_cache(InstalledPackagesMode::LeafOnly, None).unwrap();
//! println!("Found {} leaf packages", leaf_packages.len());
//! ```
//!
//! ## Search Official Packages
//!
//! ```no_run
//! use arch_toolkit::index::{fetch_official_index_async, search_official};
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! // Fetch the official index
//! let index = fetch_official_index_async().await?;
//!
//! // Search for packages (substring matching)
//! let results = search_official(&index, "vim", false);
//! for result in results {
//! println!("{}: {}", result.package.name, result.package.version);
//! }
//!
//! // Fuzzy search (requires fuzzy-search feature)
//! let fuzzy_results = search_official(&index, "rg", true);
//! for result in fuzzy_results {
//! println!("{} (score: {:?})", result.package.name, result.fuzzy_score);
//! }
//! # Ok(())
//! # }
//! ```
//!
//! ## Get All Official Packages
//!
//! ```no_run
//! use arch_toolkit::index::{all_official, fetch_official_index};
//!
//! let index = fetch_official_index()?;
//! let all_packages = all_official(&index);
//! println!("Found {} official packages", all_packages.len());
//! # Ok::<(), arch_toolkit::error::ArchToolkitError>(())
//! ```
//!
//! ## Persist the Index to Disk
//!
//! ```no_run
//! use arch_toolkit::index::{fetch_official_index, load_from_disk, save_to_disk};
//! use std::path::Path;
//!
//! let path = Path::new("official_index.json");
//!
//! // Load a cached index, falling back to a fresh fetch
//! let index = load_from_disk(path).or_else(|_| fetch_official_index())?;
//!
//! // Save the index for the next session
//! save_to_disk(&index, path)?;
//! # Ok::<(), arch_toolkit::error::ArchToolkitError>(())
//! ```
// Re-export types from types module
pub use crate;
// Re-export installed functions
pub use ;
// Re-export explicit functions
pub use ;
// Re-export query functions
pub use ;
// Re-export caller-client mirror discovery and pure mirrorlist generation
pub use ;
// Re-export cancellable background refresh
pub use ;
// Re-export fetch functions
pub use ;
// Re-export persist functions
pub use ;
pub use ;