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
/// Common utilities shared across multiple modules for code reuse and maintainability.
///
/// This module centralizes frequently used utility functions and types that are
/// duplicated across the codebase. By providing these in a single location, we
/// reduce code duplication, improve maintainability, and ensure consistency.
///
/// ## Features
///
/// - **Cryptographic Operations**: Hashing, encoding, and security utilities
/// - **JSON Utilities**: Common JSON manipulation and processing functions
/// - **General Utilities**: Time operations, thread-safe data structures, and helpers
/// - **Performance Optimized**: Efficient implementations for common operations
/// - **Thread Safe**: All utilities are safe to use across thread boundaries
///
/// ## Architecture
///
/// ### Core Components
/// - **`crypto`**: Cryptographic hashing, encoding, and security functions
/// - **`json`**: JSON manipulation, validation, and utility functions
/// - **`utils`**: General-purpose utilities including time, threading, and data structures
///
/// ## Examples
///
/// ### Time Operations
/// ```rust
/// use trash_utilities::common::utils::*;
///
/// // Current UTC time
/// let now = current_utc_time();
/// let formatted = format_datetime(&now);
/// println!("Current time: {}", formatted);
///
/// // Date parsing
/// let date = parse_date("2023-12-25").unwrap();
/// let datetime = parse_datetime("2023-12-25T00:00:00Z").unwrap();
/// ```
///
/// ### Thread-Safe Data Structures
/// ```rust
/// use trash_utilities::common::utils::*;
///
/// // Atomic counter for thread-safe counting
/// let counter = AtomicCounter::new();
/// assert_eq!(counter.increment(), 1);
/// assert_eq!(counter.get(), 1);
/// counter.reset();
/// assert_eq!(counter.get(), 0);
///
/// // String interning for memory efficiency
/// let interner = StringInterner::new();
/// let s1 = interner.intern("frequently_used");
/// let s2 = interner.intern("frequently_used");
/// assert_eq!(s1.as_ptr(), s2.as_ptr()); // Same memory location
/// assert_eq!(interner.len(), 1);
///
/// // LRU cache with size limits
/// let cache = LruCache::new(100);
/// cache.insert("key1", "value1");
/// cache.insert("key2", "value2");
/// assert_eq!(cache.get(&"key1"), Some("value1"));
/// assert_eq!(cache.len(), 2);
/// ```
///
/// ### Cryptographic Operations
/// ```rust
/// use trash_utilities::common::crypto::*;
///
/// // Fast non-cryptographic hashing
/// let hash = hash_data_fast(b"some data");
/// println!("Hash: {}", hash);
///
/// // Base64 encoding/decoding
/// let data = b"Hello, World!";
/// let encoded = encode_base64(data);
/// let decoded = decode_base64(&encoded).unwrap();
/// assert_eq!(data.to_vec(), decoded);
/// ```
///
/// ### JSON Utilities
/// ```rust
/// use trash_utilities::common::json::*;
///
/// // JSON validation
/// let json_str = r#"{"name": "Alice", "age": 30}"#;
/// assert!(validate_json_structure(json_str));
///
/// // JSON key extraction
/// let value = extract_json_value(json_str, "name");
/// assert_eq!(value, Some(r#""Alice""#.to_string()));
///
/// // JSON key existence checking
/// assert!(json_has_key(json_str, "name"));
/// assert!(!json_has_key(json_str, "email"));
/// ```
///
/// ### Performance Monitoring
/// ```rust
/// use trash_utilities::common::utils::*;
///
/// // Performance timer with automatic reporting
/// {
/// let _timer = Timer::new("expensive_operation");
/// // ... expensive operation ...
/// std::thread::sleep(std::time::Duration::from_millis(10));
/// } // Timer automatically reports duration when dropped
/// // Output: Timer 'expensive_operation' completed in 10ms
/// ```
///
/// ### Memory Management Helpers
/// ```rust
/// use trash_utilities::common::utils::*;
///
/// // Efficient string building
/// let mut builder = EfficientStringBuilder::new();
/// builder.append("Hello");
/// builder.append(", ");
/// builder.append("world!");
/// let result = builder.build();
/// assert_eq!(result, "Hello, world!");
///
/// // Memory pool allocation (if available)
/// // let ptr = alloc_from_pool("default", 1024);
/// ```
// Submodule declarations
// Re-exports for backward compatibility
pub use *;
pub use *;
pub use *;