Function parse_fallback_file

Source
pub fn parse_fallback_file(
    json: &str,
    logger: Option<&Logger>,
) -> RovenueResult<HashMap<String, String>>
Expand description

Parse a spec D1 fallback-placements file into identifier -> raw PlacementsResponse JSON string.

Storage choice: PlacementsResponse isn’t (and shouldn’t become) Clone — and the crate’s established convention for “hold a wire payload in memory, decode on demand” is already raw-JSON-string storage (see PlacementsCacheRepo/the offline-cache branch in client.rs, which re-serde_json::from_strs the cached string on every offline resolve). This function follows the same convention rather than requiring PlacementsResponse: Clone — one fewer derive to keep in sync across the wire-type tree, and PlacementsClient::get_funnel already has the decode-from-string codepath it needs to reuse.

Fails loudly — a distinct InvalidArgument error, not a silent partial result — when the file doesn’t parse as JSON at all, or when formatVersion isn’t the literal integer 1. An integrator who bundles a stale/mismatched export must see this at configure/setFallbackPlacements time, not months later when a device finally goes offline.

An individual placements entry that doesn’t decode as PlacementsResponse is SKIPPED (logged when a logger is attached, never fatal) — a partially-valid file still helps: one bad entry shouldn’t sacrifice every other placement’s offline coverage.