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(crate) use advisories::fetch_security_advisories_with_context;
33pub use aur_vote::{
34    AurPackageVoteState, AurVoteContext, AurVoteError, AurVoteOutcome, VoteAction, aur_vote,
35    aur_vote_state, is_vote_state_unsupported_error,
36};
37pub use comments::fetch_aur_comments;
38pub(crate) use comments::fetch_aur_comments_with_context;
39pub use details::fetch_details;
40pub(crate) use details::fetch_details_with_context;
41pub use feeds::{
42    NewsFeedContext, check_circuit_breaker, extract_endpoint_pattern,
43    extract_retry_after_from_error, fetch_continuation_items, fetch_news_feed,
44    get_aur_json_changes, get_official_json_changes, increase_archlinux_backoff,
45    load_official_json_cache, official_json_cache_path, optimize_max_age_for_startup,
46    rate_limit_archlinux, record_circuit_breaker_outcome, reset_archlinux_backoff,
47    take_network_error,
48};
49pub(crate) use feeds::{fetch_continuation_items_with_context, fetch_news_feed_with_context};
50pub(crate) use news::fetch_arch_news_with_context;
51pub use news::{fetch_arch_news, fetch_news_content, parse_news_html};
52pub use pkgbuild::fetch_pkgbuild_fast;
53pub(crate) use pkgbuild::fetch_pkgbuild_fast_with_context;
54pub(crate) use search::fetch_all_with_context;
55pub use search::fetch_all_with_errors;
56pub use status::fetch_arch_status_text;
57
58#[cfg(not(target_os = "windows"))]
59#[cfg(test)]
60static TEST_MUTEX: std::sync::OnceLock<std::sync::Mutex<()>> = std::sync::OnceLock::new();
61
62#[cfg(not(target_os = "windows"))]
63#[cfg(test)]
64/// What: Provide a shared mutex to serialize tests that mutate PATH or curl shims.
65///
66/// Input: None.
67/// Output: `&'static Mutex<()>` guard to synchronize tests touching global state.
68///
69/// Details: Lazily initializes a global `Mutex` via `OnceLock` for cross-test coordination.
70pub(crate) fn test_mutex() -> &'static std::sync::Mutex<()> {
71    TEST_MUTEX.get_or_init(|| std::sync::Mutex::new(()))
72}