Skip to main content

fetch

Function fetch 

Source
pub fn fetch<T: Transport>(
    client: &Client<T>,
    request: &WyomingRequest,
    now_s: u64,
) -> Result<(WyomingSounding, Fetched), WyomingError>
Expand description

Fetches request through client and reads it.

The answer comes from the client’s cache while fresh (WyomingRequest::source at now_s, seconds since the Unix epoch); offline, from the cache only. The Fetched says which, carries ATTRIBUTION and holds the body. Only an answer that parses and makes a sounding is cached (Client::fetch_checked): one that doesn’t never takes a good copy’s place, and online a stale good copy is returned instead, with the reason. A sounding the archive doesn’t have is an HTTP error (404; 400 for a BUFR file a station doesn’t send), which the transport reports.

§Errors

WyomingError::Request for a bad request; WyomingError::Net when the fetch fails, or with NetError::Refused naming what WyomingSounding::parse or WyomingSounding::sounding refused when the only answer there is doesn’t pass them.