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 (planned)
12//! - `install`: Installation command building (planned)
13//! - `news`: News feeds and security advisories (planned)
14//! - `sandbox`: PKGBUILD security analysis (planned)
15//!
16//! # Examples
17//!
18//! ## Basic AUR Search
19//!
20//! ```no_run
21//! use arch_toolkit::ArchClient;
22//!
23//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
24//! let client = ArchClient::new()?;
25//! let packages = client.aur().search("yay").await?;
26//! println!("Found {} packages", packages.len());
27//! # Ok(())
28//! # }
29//! ```
30//!
31//! ## Fetch Package Details
32//!
33//! ```no_run
34//! use arch_toolkit::ArchClient;
35//!
36//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
37//! let client = ArchClient::new()?;
38//! let details = client.aur().info(&["yay", "paru"]).await?;
39//! for pkg in details {
40//! println!("{}: {}", pkg.name, pkg.description);
41//! }
42//! # Ok(())
43//! # }
44//! ```
45//!
46//! ## Custom Configuration
47//!
48//! ```no_run
49//! use arch_toolkit::ArchClient;
50//! use std::time::Duration;
51//!
52//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
53//! let client = ArchClient::builder()
54//! .timeout(Duration::from_secs(60))
55//! .user_agent("my-app/1.0")
56//! .build()?;
57//! let packages = client.aur().search("yay").await?;
58//! # Ok(())
59//! # }
60//! ```
61//!
62//! ## Fetch Comments
63//!
64//! ```no_run
65//! use arch_toolkit::ArchClient;
66//!
67//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
68//! let client = ArchClient::new()?;
69//! let comments = client.aur().comments("yay").await?;
70//! for comment in comments.iter().take(5) {
71//! println!("{}: {}", comment.author, comment.content);
72//! }
73//! # Ok(())
74//! # }
75//! ```
76//!
77//! ## Fetch PKGBUILD
78//!
79//! ```no_run
80//! use arch_toolkit::ArchClient;
81//!
82//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
83//! let client = ArchClient::new()?;
84//! let pkgbuild = client.aur().pkgbuild("yay").await?;
85//! println!("PKGBUILD:\n{}", pkgbuild);
86//! # Ok(())
87//! # }
88//! ```
89//!
90//! ## Dependency Resolution
91//!
92//! ```ignore
93//! use arch_toolkit::deps::DependencyResolver;
94//! use arch_toolkit::{PackageRef, PackageSource};
95//!
96//! let resolver = DependencyResolver::new();
97//! let packages = vec![
98//! PackageRef {
99//! name: "firefox".into(),
100//! version: "121.0".into(),
101//! source: PackageSource::Official {
102//! repo: "extra".into(),
103//! arch: "x86_64".into(),
104//! },
105//! },
106//! ];
107//!
108//! let result = resolver.resolve(&packages).unwrap();
109//! println!("Found {} dependencies", result.dependencies.len());
110//! ```
111//!
112//! ## Parse Dependency Specifications
113//!
114//! ```ignore
115//! use arch_toolkit::deps::parse_dep_spec;
116//!
117//! let spec = parse_dep_spec("python>=3.12");
118//! println!("Package: {}, Version: {}", spec.name, spec.version_req);
119//! ```
120//!
121//! ## Query Installed Packages
122//!
123//! ```ignore
124//! use arch_toolkit::deps::get_installed_packages;
125//!
126//! let installed = get_installed_packages().unwrap();
127//! println!("Found {} installed packages", installed.len());
128//! ```
129
130pub mod error;
131pub mod types;
132
133#[cfg(feature = "aur")]
134pub mod aur;
135
136#[cfg(feature = "aur")]
137pub mod client;
138
139#[cfg(feature = "aur")]
140pub mod cache;
141
142#[cfg(feature = "aur")]
143pub mod health;
144
145#[cfg(feature = "aur")]
146mod env;
147
148#[cfg(feature = "deps")]
149pub mod deps;
150
151/// Prelude module for convenient imports.
152///
153/// This module re-exports commonly used types, traits, and functions,
154/// allowing you to import everything you need with a single `use arch_toolkit::prelude::*;`.
155///
156/// # Example
157///
158/// ```no_run
159/// use arch_toolkit::prelude::*;
160///
161/// # async fn example() -> Result<()> {
162/// let client = ArchClient::new()?;
163/// let packages: Vec<AurPackage> = client.aur().search("yay").await?;
164/// Ok(())
165/// # }
166/// ```
167pub mod prelude;
168
169// Re-export commonly used types
170pub use error::{ArchToolkitError as Error, Result};
171pub use types::{AurComment, AurPackage, AurPackageDetails};
172
173#[cfg(feature = "aur")]
174pub use types::{HealthStatus, ServiceStatus};
175
176#[cfg(feature = "deps")]
177pub use types::{
178 Dependency, DependencySource, DependencySpec, DependencyStatus, PackageRef, PackageSource,
179 ReverseDependencySummary, SrcinfoData,
180};
181
182#[cfg(feature = "deps")]
183pub use deps::{
184 DependencyResolution, DependencyResolver, ResolverConfig, ReverseDependencyAnalyzer,
185 ReverseDependencyReport,
186};
187
188#[cfg(feature = "aur")]
189pub use aur::{AurApi, MockAurApi};
190
191#[cfg(feature = "aur")]
192pub use client::{ArchClient, ArchClientBuilder, CacheInvalidator, RetryPolicy};
193
194#[cfg(feature = "aur")]
195pub use cache::{CacheConfig, CacheConfigBuilder};
196
197#[cfg(feature = "aur")]
198pub use aur::validation::ValidationConfig;