Iterate over every `Sandbox` in the store and collect items produced by `f`. `f` receives each decoded sandbox; returning `Some(T)` includes the value in the output, `None` skips it. This is the shared pagination kernel used by all sandbox-scan helpers.
(store: &Store, mut f: F)
| 317 | /// |
| 318 | /// This is the shared pagination kernel used by all sandbox-scan helpers. |
| 319 | async fn scan_sandboxes<T, F>(store: &Store, mut f: F) -> Result<Vec<T>, Status> |
| 320 | where |
| 321 | F: FnMut(Sandbox) -> Option<T>, |
| 322 | { |
| 323 | let mut out = Vec::new(); |
| 324 | let mut offset = 0u32; |
| 325 | loop { |
| 326 | let records = store |
| 327 | .list(Sandbox::object_type(), 1000, offset) |
| 328 | .await |
| 329 | .map_err(|e| Status::internal(format!("list sandboxes failed: {e}")))?; |
| 330 | if records.is_empty() { |
| 331 | break; |
| 332 | } |
| 333 | offset = offset |
| 334 | .checked_add( |
| 335 | u32::try_from(records.len()) |
| 336 | .map_err(|_| Status::internal("sandbox page size exceeded u32"))?, |
| 337 | ) |
| 338 | .ok_or_else(|| Status::internal("sandbox pagination offset overflow"))?; |
| 339 | for record in records { |
| 340 | let sandbox = Sandbox::decode(record.payload.as_slice()) |
| 341 | .map_err(|e| Status::internal(format!("decode sandbox failed: {e}")))?; |
| 342 | if let Some(item) = f(sandbox) { |
| 343 | out.push(item); |
| 344 | } |
| 345 | } |
| 346 | } |
| 347 | Ok(out) |
| 348 | } |
| 349 | |
| 350 | async fn sandboxes_using_provider( |
| 351 | store: &Store, |
no test coverage detected