Skip to main content

arch_toolkit/
lib.rs

1//! Complete Rust toolkit for Arch Linux package management.
2//!
3//! This crate provides a unified API for interacting with Arch Linux package management,
4//! including AUR (Arch User Repository) operations, dependency resolution, package
5//! index queries, installation command building, news feeds, and security advisories.
6//!
7//! # Features
8//!
9//! - `aur`: AUR search, package info, comments, and PKGBUILD fetching
10//! - `deps`: Dependency resolution, parsing, and reverse dependency analysis
11//! - `index`: Package database queries (installed and explicit package tracking)
12//! - `install`: Installation command building (pacman, AUR helpers, batch planning)
13//! - `news`: Arch news RSS and security advisories
14//! - `sandbox`: Build-preflight dependency analysis (PKGBUILD/.SRCINFO vs host)
15//!
16//! # Examples
17//!
18//! ## Basic AUR Search
19//!
20//! ```no_run
21//! # #[cfg(feature = "aur")] mod wrap {
22//! use arch_toolkit::ArchClient;
23//!
24//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
25//! let client = ArchClient::new()?;
26//! let packages = client.aur().search("yay").await?;
27//! println!("Found {} packages", packages.len());
28//! # Ok(())
29//! # }
30//! # }
31//! ```
32//!
33//! ## Fetch Package Details
34//!
35//! ```no_run
36//! # #[cfg(feature = "aur")] mod wrap {
37//! use arch_toolkit::ArchClient;
38//!
39//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
40//! let client = ArchClient::new()?;
41//! let details = client.aur().info(&["yay", "paru"]).await?;
42//! for pkg in details {
43//!     println!("{}: {}", pkg.name, pkg.description);
44//! }
45//! # Ok(())
46//! # }
47//! # }
48//! ```
49//!
50//! ## Custom Configuration
51//!
52//! ```no_run
53//! # #[cfg(feature = "aur")] mod wrap {
54//! use arch_toolkit::ArchClient;
55//! use std::time::Duration;
56//!
57//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
58//! let client = ArchClient::builder()
59//!     .timeout(Duration::from_secs(60))
60//!     .user_agent("my-app/1.0")
61//!     .build()?;
62//! let packages = client.aur().search("yay").await?;
63//! # Ok(())
64//! # }
65//! # }
66//! ```
67//!
68//! ## Fetch Comments
69//!
70//! ```no_run
71//! # #[cfg(feature = "aur")] mod wrap {
72//! use arch_toolkit::ArchClient;
73//!
74//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
75//! let client = ArchClient::new()?;
76//! let comments = client.aur().comments("yay").await?;
77//! for comment in comments.iter().take(5) {
78//!     println!("{}: {}", comment.author, comment.content);
79//! }
80//! # Ok(())
81//! # }
82//! # }
83//! ```
84//!
85//! ## Fetch PKGBUILD
86//!
87//! ```no_run
88//! # #[cfg(feature = "aur")] mod wrap {
89//! use arch_toolkit::ArchClient;
90//!
91//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
92//! let client = ArchClient::new()?;
93//! let pkgbuild = client.aur().pkgbuild("yay").await?;
94//! println!("PKGBUILD:\n{}", pkgbuild);
95//! # Ok(())
96//! # }
97//! # }
98//! ```
99//!
100//! ## Dependency Resolution
101//!
102//! ```ignore
103//! use arch_toolkit::deps::DependencyResolver;
104//! use arch_toolkit::{PackageRef, PackageSource};
105//!
106//! let resolver = DependencyResolver::new();
107//! let packages = vec![
108//!     PackageRef {
109//!         name: "firefox".into(),
110//!         version: "121.0".into(),
111//!         source: PackageSource::Official {
112//!             repo: "extra".into(),
113//!             arch: "x86_64".into(),
114//!         },
115//!     },
116//! ];
117//!
118//! let result = resolver.resolve(&packages).unwrap();
119//! println!("Found {} dependencies", result.dependencies.len());
120//! ```
121//!
122//! ## Parse Dependency Specifications
123//!
124//! ```ignore
125//! use arch_toolkit::deps::parse_dep_spec;
126//!
127//! let spec = parse_dep_spec("python>=3.12");
128//! println!("Package: {}, Version: {}", spec.name, spec.version_req);
129//! ```
130//!
131//! ## Query Installed Packages
132//!
133//! ```ignore
134//! use arch_toolkit::deps::get_installed_packages;
135//!
136//! let installed = get_installed_packages().unwrap();
137//! println!("Found {} installed packages", installed.len());
138//! ```
139
140pub mod error;
141pub mod types;
142
143#[cfg(feature = "aur")]
144pub mod aur;
145
146#[cfg(feature = "aur")]
147pub mod client;
148
149#[cfg(feature = "aur")]
150pub mod cache;
151
152#[cfg(feature = "aur")]
153pub mod health;
154
155#[cfg(feature = "aur")]
156mod env;
157
158#[cfg(feature = "aur")]
159mod http;
160
161#[cfg(feature = "deps")]
162pub mod deps;
163
164#[cfg(feature = "index")]
165pub mod index;
166
167#[cfg(feature = "install")]
168pub mod install;
169
170#[cfg(feature = "news")]
171pub mod news;
172
173#[cfg(feature = "sandbox")]
174pub mod sandbox;
175
176/// Prelude module for convenient imports.
177///
178/// This module re-exports commonly used types, traits, and functions,
179/// allowing you to import everything you need with a single `use arch_toolkit::prelude::*;`.
180///
181/// # Example
182///
183/// ```no_run
184/// # #[cfg(feature = "aur")] mod wrap {
185/// use arch_toolkit::prelude::*;
186///
187/// # async fn example() -> Result<()> {
188/// let client = ArchClient::new()?;
189/// let packages: Vec<AurPackage> = client.aur().search("yay").await?;
190/// Ok(())
191/// # }
192/// # }
193/// ```
194pub mod prelude;
195
196// Re-export commonly used types
197pub use error::{ArchToolkitError as Error, Result};
198pub use types::{AurComment, AurPackage, AurPackageDetails};
199
200#[cfg(feature = "aur")]
201pub use types::{HealthStatus, ServiceStatus};
202
203#[cfg(feature = "deps")]
204pub use types::{
205    Dependency, DependencySource, DependencySpec, DependencyStatus, PackageRef, PackageSource,
206    ReverseDependencySummary, SrcinfoData,
207};
208
209#[cfg(feature = "deps")]
210pub use types::dependency::{
211    DependencyConstraintRange, DependencyGraphConfig, DependencyGraphDiagnostic,
212    DependencyGraphDiagnosticKind, DependencyGraphEdge, DependencyGraphNode,
213    DependencyGraphNodeStatus, DependencyGraphResolution, DependencyMetadata,
214    DependencyMetadataResponse, DependencyProvenance, DependencyVersionBound,
215};
216
217#[cfg(feature = "index")]
218pub use types::index::{
219    IndexQueryResult, InstalledPackagesMode, MirrorDiscoveryLimits, MirrorInfo, OfficialIndex,
220    OfficialPackage,
221};
222
223#[cfg(feature = "install")]
224pub use types::install::{AurHelper, CascadeMode, CommandSpec, InstallOptions, PrivilegeTool};
225
226#[cfg(feature = "news")]
227pub use types::news::{AdvisorySeverity, ArchNewsItem, SecurityAdvisory};
228
229#[cfg(feature = "news")]
230pub use news::{FeedCache, InMemoryFeedCache};
231
232#[cfg(feature = "sandbox")]
233pub use types::sandbox::{
234    DependencyDelta, SandboxAnalysisLimitation, SandboxFinding, SandboxInfo, SandboxRuleId,
235    SandboxStaticAnalysis,
236};
237
238#[cfg(all(feature = "aur", feature = "index"))]
239pub use aur::{
240    ARCH_PACKAGE_SEARCH_URL, check_mirror_health, fetch_arch_package_detail,
241    fetch_official_package_detail_from,
242};
243
244#[cfg(all(feature = "aur", feature = "index"))]
245pub use types::package::{
246    MetadataFetchLimits, MirrorHealth, MirrorHealthLimits, MirrorHealthStatus,
247};
248
249#[cfg(feature = "deps")]
250pub use deps::{
251    DependencyMetadataProvider, DependencyResolution, DependencyResolver, ResolverConfig,
252    ReverseDependencyAnalyzer, ReverseDependencyReport,
253};
254
255#[cfg(feature = "aur")]
256pub use aur::{AurApi, MockAurApi};
257
258#[cfg(feature = "aur")]
259pub use client::{ArchClient, ArchClientBuilder, CacheInvalidator, RetryPolicy};
260
261#[cfg(feature = "aur")]
262pub use cache::{CacheConfig, CacheConfigBuilder};
263
264#[cfg(feature = "aur")]
265pub use aur::validation::ValidationConfig;