pacsea/sources/
mod.rs

1//! Network and system data retrieval module split into submodules.
2
3/// Security advisories fetching.
4mod advisories;
5/// AUR comments fetching.
6mod comments;
7/// Package details fetching.
8mod details;
9/// News feed fetching.
10mod feeds;
11/// Arch Linux news fetching.
12pub mod news;
13/// PKGBUILD content fetching.
14mod pkgbuild;
15/// Package search functionality.
16mod search;
17/// Arch Linux status page monitoring.
18pub mod status;
19
20/// What: Result type alias for sources module errors.
21///
22/// Inputs: None (type alias).
23///
24/// Output: Result type with boxed error trait object.
25///
26/// Details: Standard error type for network and parsing operations in the sources module.
27type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
28
29pub use advisories::fetch_security_advisories;
30pub use comments::fetch_aur_comments;
31pub use details::fetch_details;
32pub use feeds::{
33    NewsFeedContext, check_circuit_breaker, extract_endpoint_pattern,
34    extract_retry_after_from_error, fetch_continuation_items, fetch_news_feed,
35    get_aur_json_changes, get_official_json_changes, increase_archlinux_backoff,
36    load_official_json_cache, official_json_cache_path, optimize_max_age_for_startup,
37    rate_limit_archlinux, record_circuit_breaker_outcome, reset_archlinux_backoff,
38    take_network_error,
39};
40pub use news::{fetch_arch_news, fetch_news_content, parse_news_html};
41pub use pkgbuild::fetch_pkgbuild_fast;
42pub use search::fetch_all_with_errors;
43pub use status::fetch_arch_status_text;
44
45#[cfg(not(target_os = "windows"))]
46#[cfg(test)]
47static TEST_MUTEX: std::sync::OnceLock<std::sync::Mutex<()>> = std::sync::OnceLock::new();
48
49#[cfg(not(target_os = "windows"))]
50#[cfg(test)]
51/// What: Provide a shared mutex to serialize tests that mutate PATH or curl shims.
52///
53/// Input: None.
54/// Output: `&'static Mutex<()>` guard to synchronize tests touching global state.
55///
56/// Details: Lazily initializes a global `Mutex` via `OnceLock` for cross-test coordination.
57pub(crate) fn test_mutex() -> &'static std::sync::Mutex<()> {
58    TEST_MUTEX.get_or_init(|| std::sync::Mutex::new(()))
59}