Fetches the current worldwide total from the worker. Returns None on timeout, network error, or parse failure.
()
| 58 | /// Fetches the current worldwide total from the worker. |
| 59 | /// Returns None on timeout, network error, or parse failure. |
| 60 | pub fn fetch_worldwide_total() -> Option<u64> { |
| 61 | let agent = agent_with_timeout(FETCH_TIMEOUT); |
| 62 | let parsed: WorkerResponse = agent |
| 63 | .get(&format!("{WORKER_URL}/total")) |
| 64 | .call() |
| 65 | .ok()? |
| 66 | .body_mut() |
| 67 | .read_json() |
| 68 | .ok()?; |
| 69 | Some(parsed.total) |
| 70 | } |
| 71 | |
| 72 | /// Response from the worker's GET /countries endpoint. |
| 73 | #[derive(serde::Deserialize)] |
no test coverage detected