Skip to main content

arch_toolkit/
prelude.rs

1//! Prelude module for convenient imports.
2//!
3//! This module re-exports commonly used types, traits, and functions from arch-toolkit,
4//! allowing you to import everything you need with a single `use arch_toolkit::prelude::*;`.
5//!
6//! # Examples
7//!
8//! ## Basic Usage
9//!
10//! ```no_run
11//! # #[cfg(feature = "aur")] mod wrap {
12//! use arch_toolkit::prelude::*;
13//!
14//! # async fn example() -> Result<()> {
15//! let client = ArchClient::new()?;
16//! let packages: Vec<AurPackage> = client.aur().search("yay").await?;
17//! Ok(())
18//! # }
19//! # }
20//! ```
21//!
22//! ## With Custom Configuration
23//!
24//! ```no_run
25//! # #[cfg(feature = "aur")] mod wrap {
26//! use arch_toolkit::prelude::*;
27//! use std::time::Duration;
28//!
29//! # async fn example() -> Result<()> {
30//! let client = ArchClient::builder()
31//!     .timeout(Duration::from_secs(60))
32//!     .user_agent("my-app/1.0")
33//!     .build()?;
34//! let packages = client.aur().search("yay").await?;
35//! Ok(())
36//! # }
37//! # }
38//! ```
39//!
40//! ## Using Mock for Testing
41//!
42//! ```no_run
43//! # #[cfg(feature = "aur")] mod wrap {
44//! use arch_toolkit::prelude::*;
45//!
46//! # async fn example() -> Result<()> {
47//! let mock = MockAurApi::new()
48//!     .with_search_result("yay", Ok(vec![]));
49//! let packages = mock.search("yay").await?;
50//! Ok(())
51//! # }
52//! # }
53//! ```
54//!
55//! ## Dependency Resolution
56//!
57//! ```ignore
58//! use arch_toolkit::prelude::*;
59//!
60//! let resolver = DependencyResolver::new();
61//! let packages = vec![
62//!     PackageRef {
63//!         name: "firefox".into(),
64//!         version: "121.0".into(),
65//!         source: PackageSource::Official {
66//!             repo: "extra".into(),
67//!             arch: "x86_64".into(),
68//!         },
69//!     },
70//! ];
71//!
72//! let result = resolver.resolve(&packages).unwrap();
73//! println!("Found {} dependencies", result.dependencies.len());
74//! ```
75
76// Core client types
77#[cfg(feature = "aur")]
78pub use crate::client::{ArchClient, ArchClientBuilder};
79
80// Data types
81pub use crate::types::{AurComment, AurPackage, AurPackageDetails};
82
83// Error handling
84pub use crate::error::{ArchToolkitError as Error, Result};
85
86// Traits
87#[cfg(feature = "aur")]
88pub use crate::aur::AurApi;
89
90// Testing
91#[cfg(feature = "aur")]
92pub use crate::aur::MockAurApi;
93
94// Configuration types
95#[cfg(feature = "aur")]
96pub use crate::cache::{CacheConfig, CacheConfigBuilder};
97
98#[cfg(feature = "aur")]
99pub use crate::aur::validation::ValidationConfig;
100
101#[cfg(feature = "aur")]
102pub use crate::client::RetryPolicy;
103
104#[cfg(feature = "aur")]
105pub use crate::client::CacheInvalidator;
106
107// Health types
108#[cfg(feature = "aur")]
109pub use crate::types::{HealthStatus, ServiceStatus};
110
111// Dependency types and functions
112#[cfg(feature = "deps")]
113pub use crate::types::{
114    Dependency, DependencySource, DependencySpec, DependencyStatus, PackageRef, PackageSource,
115    ReverseDependencySummary, SrcinfoData,
116};
117
118#[cfg(feature = "deps")]
119pub use crate::types::dependency::{
120    DependencyConstraintRange, DependencyGraphConfig, DependencyGraphDiagnostic,
121    DependencyGraphDiagnosticKind, DependencyGraphEdge, DependencyGraphNode,
122    DependencyGraphNodeStatus, DependencyGraphResolution, DependencyMetadata,
123    DependencyMetadataResponse, DependencyProvenance, DependencyVersionBound,
124};
125
126#[cfg(feature = "deps")]
127pub use crate::deps::{
128    DependencyMetadataProvider, DependencyResolution, DependencyResolver, ResolverConfig,
129    ReverseDependencyAnalyzer, ReverseDependencyReport, get_installed_packages, parse_dep_spec,
130    version_satisfies,
131};
132
133// Index types and functions
134#[cfg(feature = "index")]
135pub use crate::types::index::{
136    IndexQueryResult, InstalledPackagesMode, MirrorDiscoveryLimits, MirrorInfo, OfficialIndex,
137    OfficialPackage,
138};
139
140#[cfg(feature = "index")]
141pub use crate::index::{
142    IndexRefreshHandle, detect_enabled_repos, fetch_arch_mirrors, fetch_mirrors_from,
143    fetch_official_index, fetch_official_index_for_repos, generate_mirrorlist, load_from_disk,
144    load_from_disk_or_default, save_to_disk, search_official, spawn_index_refresh,
145};
146
147// Install types and functions
148#[cfg(feature = "install")]
149pub use crate::types::install::{
150    AurHelper, CascadeMode, CommandSpec, InstallOptions, PrivilegeTool,
151};
152
153#[cfg(feature = "install")]
154pub use crate::install::{
155    InstallPlan, aur_install_shell_fallback, aur_update_shell_fallback, build_aur_install,
156    build_aur_update_command, build_batch_install, build_force_sync_update_command,
157    build_pacman_install, build_remove_command, build_update_command, detect_aur_helper,
158    detect_privilege_tool, with_privilege,
159};
160
161// News types and functions
162#[cfg(feature = "news")]
163pub use crate::types::news::{AdvisorySeverity, ArchNewsItem, SecurityAdvisory};
164
165#[cfg(feature = "news")]
166pub use crate::news::{
167    FeedCache, InMemoryFeedCache, extract_article_text, fetch_arch_news, fetch_arch_news_cached,
168    fetch_article_text, fetch_security_advisories, fetch_security_advisories_cached,
169};
170
171// Sandbox types and functions
172#[cfg(feature = "sandbox")]
173pub use crate::types::sandbox::{
174    DependencyDelta, SandboxAnalysisLimitation, SandboxFinding, SandboxInfo, SandboxRuleId,
175    SandboxStaticAnalysis,
176};
177
178#[cfg(feature = "sandbox")]
179pub use crate::sandbox::{analyze_pkgbuild, analyze_pkgbuild_security, analyze_srcinfo};
180
181// Official metadata and mirror-health capability types/functions
182#[cfg(all(feature = "aur", feature = "index"))]
183pub use crate::aur::{
184    ARCH_PACKAGE_SEARCH_URL, check_mirror_health, fetch_arch_package_detail,
185    fetch_official_package_detail_from,
186};
187
188#[cfg(all(feature = "aur", feature = "index"))]
189pub use crate::types::package::{
190    MetadataFetchLimits, MirrorHealth, MirrorHealthLimits, MirrorHealthStatus,
191};