Skip to main content

pacsea/sources/
mod.rs

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