spotify_cli/constants.rs
1//! Application-wide constants.
2//!
3//! Centralizes configuration values that are used across multiple modules.
4
5// =============================================================================
6// API Configuration
7// =============================================================================
8
9/// Base URL for Spotify Web API endpoints.
10pub const SPOTIFY_API_BASE_URL: &str = "https://api.spotify.com/v1";
11
12/// Base URL for Spotify authentication endpoints.
13pub const SPOTIFY_AUTH_BASE_URL: &str = "https://accounts.spotify.com";
14
15/// Maximum number of retries for rate-limited API requests.
16pub const MAX_API_RETRIES: u32 = 3;
17
18// =============================================================================
19// OAuth Configuration
20// =============================================================================
21
22/// Default port for the OAuth callback server.
23pub const DEFAULT_OAUTH_PORT: u16 = 8888;
24
25/// Path where Spotify redirects after authorization.
26pub const OAUTH_CALLBACK_PATH: &str = "/callback";
27
28/// Timeout in seconds for waiting for OAuth callback.
29pub const OAUTH_CALLBACK_TIMEOUT_SECS: u64 = 300;
30
31/// Length of the PKCE verifier string.
32pub const PKCE_VERIFIER_LENGTH: usize = 128;
33
34// =============================================================================
35// Token Management
36// =============================================================================
37
38/// Buffer in seconds before token expiry to consider it expired.
39/// Tokens are refreshed this many seconds before actual expiry.
40pub const TOKEN_EXPIRY_BUFFER_SECS: u64 = 60;
41
42// =============================================================================
43// Storage
44// =============================================================================
45
46/// Application directory name for config storage.
47pub const APP_DIR_NAME: &str = "spotify-cli";
48
49/// Filename for storing OAuth tokens.
50pub const TOKEN_FILENAME: &str = "token.json";
51
52/// Filename for storing pins.
53pub const PINS_FILENAME: &str = "pins.json";
54
55/// Filename for configuration.
56pub const CONFIG_FILENAME: &str = "config.toml";
57
58// =============================================================================
59// Pagination
60// =============================================================================
61
62/// Default limit for paginated requests.
63pub const DEFAULT_LIMIT: u8 = 20;
64
65/// Maximum allowed limit for most Spotify endpoints.
66pub const MAX_LIMIT: u8 = 50;
67
68/// Default offset for paginated requests.
69pub const DEFAULT_OFFSET: u32 = 0;
70
71// =============================================================================
72// Search
73// =============================================================================
74
75/// Default limit for search results per type.
76pub const DEFAULT_SEARCH_LIMIT: u8 = DEFAULT_LIMIT;
77
78/// Maximum allowed search limit per type.
79pub const MAX_SEARCH_LIMIT: u8 = MAX_LIMIT;