1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
//! Common constants used throughout Revue
//!
//! This module centralizes magic numbers and commonly used values to improve
//! maintainability and ensure consistency across the codebase.
//!
//! # Duration Constants
//!
//! ```rust
//! use revue::constants::*;
//! use std::time::Duration;
//!
//! // Animation durations
//! assert_eq!(ANIMATION_DEFAULT_DURATION, Duration::from_millis(300));
//! assert_eq!(ANIMATION_FAST_DURATION, Duration::from_millis(150));
//!
//! // Frame rates
//! assert_eq!(FRAME_DURATION_60FPS, Duration::from_millis(16));
//! ```
use Duration;
// =============================================================================
// File Size Constants
// =============================================================================
/// One kilobyte in bytes (1024 bytes)
pub const KB: u64 = 1024;
/// One megabyte in bytes (1024 KB)
pub const MB: u64 = 1024 * KB;
/// One gigabyte in bytes (1024 MB)
pub const GB: u64 = 1024 * MB;
/// Maximum CSS file size (1MB)
///
/// Used to prevent DoS attacks when loading CSS files.
pub const MAX_CSS_FILE_SIZE: u64 = MB;
/// Maximum config file size (1MB)
///
/// Used to prevent DoS attacks when loading config files.
pub const MAX_CONFIG_FILE_SIZE: u64 = MB;
/// Maximum snapshot file size (10MB)
///
/// Snapshots can be large, so we allow more space than CSS/config files.
pub const MAX_SNAPSHOT_FILE_SIZE: u64 = 10 * MB;
/// Maximum clipboard content size (10MB)
///
/// Used to prevent DoS attacks when reading from the system clipboard.
pub const MAX_CLIPBOARD_SIZE: usize = 10 * MB as usize;
/// Maximum paste event size (100KB)
///
/// Used to prevent DoS attacks through terminal paste events.
/// Terminal paste can be triggered by bracketed paste mode, which
/// could potentially allow injection of very large content.
pub const MAX_PASTE_SIZE: usize = 100 * KB as usize;
/// Maximum task queue size for pooled task runner
///
/// Maximum number of pending tasks in the thread pool queue.
/// Prevents unbounded memory growth when spawning many tasks.
pub const MAX_TASK_QUEUE_SIZE: usize = 1000;
/// Maximum comment length in CSS (100KB)
///
/// Used to prevent unreasonably long comments in CSS parsing.
pub const MAX_COMMENT_LENGTH: usize = 100 * KB as usize;
// =============================================================================
// Frame Rate Constants
// =============================================================================
/// Duration for ~60 FPS frame rate (16.67ms rounded to 16ms)
///
/// Used for the main event loop tick rate when targeting smooth animations.
pub const FRAME_DURATION_60FPS: Duration = from_millis;
/// Duration for ~30 FPS frame rate
///
/// Used for less demanding applications or when battery life is a concern.
pub const FRAME_DURATION_30FPS: Duration = from_millis;
// =============================================================================
// Animation Duration Constants
// =============================================================================
/// Default animation duration (300ms)
///
/// Standard duration for most transitions and animations.
/// Provides a smooth feel without being too slow.
pub const ANIMATION_DEFAULT_DURATION: Duration = from_millis;
/// Fast animation duration (150ms)
///
/// Used for quick feedback animations like button presses or hover states.
pub const ANIMATION_FAST_DURATION: Duration = from_millis;
/// Slow animation duration (500ms)
///
/// Used for more dramatic animations like modal appearances or page transitions.
pub const ANIMATION_SLOW_DURATION: Duration = from_millis;
/// Very slow animation duration (1000ms)
///
/// Used for complex choreographed animations or loading sequences.
pub const ANIMATION_VERY_SLOW_DURATION: Duration = from_millis;
// =============================================================================
// Debounce / Throttle Constants
// =============================================================================
/// Default debounce duration (100ms)
///
/// Standard delay for input debouncing to prevent excessive updates.
pub const DEBOUNCE_DEFAULT: Duration = from_millis;
/// Search debounce duration (150ms)
///
/// Slightly longer debounce for search inputs to reduce API calls.
pub const DEBOUNCE_SEARCH: Duration = from_millis;
/// File system debounce duration (100ms)
///
/// Debounce for file watcher events (hot reload).
pub const DEBOUNCE_FILE_SYSTEM: Duration = from_millis;
// =============================================================================
// Tick / Poll Constants
// =============================================================================
/// Default tick rate (50ms)
///
/// Standard polling interval for event readers.
pub const TICK_RATE_DEFAULT: Duration = from_millis;
/// Immediate poll (0ms)
///
/// Non-blocking poll for checking event availability.
pub const POLL_IMMEDIATE: Duration = from_millis;
// =============================================================================
// Screen Transition Constants
// =============================================================================
/// Screen transition duration (200ms)
///
/// Duration for screen/page transitions in multi-screen apps.
pub const SCREEN_TRANSITION_DURATION: Duration = from_millis;
// =============================================================================
// Stagger / Delay Constants
// =============================================================================
/// Default stagger delay (50ms)
///
/// Delay between animated items in a staggered animation sequence.
pub const STAGGER_DELAY_DEFAULT: Duration = from_millis;
// =============================================================================
// Message / Toast Constants
// =============================================================================
/// Default message display duration (3 seconds)
///
/// How long toast messages and notifications are shown by default.
pub const MESSAGE_DEFAULT_DURATION: Duration = from_secs;
/// Quick message display duration (2 seconds)
///
/// Shorter duration for less important notifications.
pub const MESSAGE_QUICK_DURATION: Duration = from_secs;
/// Long message display duration (5 seconds)
///
/// Longer duration for important messages that need more reading time.
pub const MESSAGE_LONG_DURATION: Duration = from_secs;
// =============================================================================
// Test / Debug Constants
// =============================================================================
/// Test sleep duration (10ms)
///
/// Short sleep used in tests to allow async operations to complete.
pub const TEST_SLEEP_SHORT: Duration = from_millis;
/// Test sleep duration (50ms)
///
/// Medium sleep used in tests for operations that need more time.
pub const TEST_SLEEP_MEDIUM: Duration = from_millis;
/// Test sleep duration (100ms)
///
/// Longer sleep for tests that need to wait for multiple operations.
pub const TEST_SLEEP_LONG: Duration = from_millis;
// =============================================================================
// Profiler Constants
// =============================================================================
/// Profiler report interval (5 seconds)
///
/// How often the profiler plugin reports metrics.
pub const PROFILER_REPORT_INTERVAL: Duration = from_secs;
/// FPS counter window (1 second)
///
/// Time window for calculating average FPS.
pub const FPS_COUNTER_WINDOW: Duration = from_secs;
// Tests extracted to tests/core_constants_tests.rs
// All constant value tests use only public constants