pacsea/state/app_state/constants.rs
1//! Constants and type aliases for `AppState`.
2
3use std::num::NonZeroUsize;
4
5/// Maximum number of recent searches to retain (most-recent-first).
6pub const RECENT_CAPACITY: usize = 20;
7
8/// What: Provide the non-zero capacity used by the LRU recent cache.
9///
10/// Inputs: None.
11///
12/// Output:
13/// - Non-zero capacity for the recent LRU cache.
14///
15/// Details:
16/// - Uses a const unchecked constructor because the capacity constant is guaranteed
17/// to be greater than zero.
18#[must_use]
19pub const fn recent_capacity() -> NonZeroUsize {
20 // SAFETY: `RECENT_CAPACITY` is a non-zero constant.
21 unsafe { NonZeroUsize::new_unchecked(RECENT_CAPACITY) }
22}
23
24/// File database sync result type.
25pub type FileSyncResult = std::sync::Arc<std::sync::Mutex<Option<Result<bool, String>>>>;