Validate the configuration
(&self)
| 181 | |
| 182 | /// Validate the configuration |
| 183 | pub fn validate(&self) -> Result<(), String> { |
| 184 | if !self.enabled { |
| 185 | return Ok(()); |
| 186 | } |
| 187 | |
| 188 | let total_memory = self.l1_config.max_memory_bytes |
| 189 | + self.l2_config.max_memory_bytes |
| 190 | + self.l3_config.max_memory_bytes; |
| 191 | |
| 192 | if total_memory > self.max_memory_bytes { |
| 193 | return Err(format!( |
| 194 | "Sum of level memory limits ({} bytes) exceeds max memory ({} bytes)", |
| 195 | total_memory, self.max_memory_bytes |
| 196 | )); |
| 197 | } |
| 198 | |
| 199 | if self.l1_config.max_entries == 0 |
| 200 | || self.l2_config.max_entries == 0 |
| 201 | || self.l3_config.max_entries == 0 |
| 202 | { |
| 203 | return Err("Cache levels must have max_entries > 0".to_string()); |
| 204 | } |
| 205 | |
| 206 | Ok(()) |
| 207 | } |
| 208 | } |
no outgoing calls
no test coverage detected