Expand description
Optional online data sources with an on-disk cache and an explicit offline mode: weather, soundings, elevation, ThrustCurve and motor stock.
Online data and the cache says what works today and what is planned.
Status: pre-alpha, with six data sources:
open_meteo: a launch site’s weather as a sounding, the first of the weather sources. The weather page explains it.wyoming: weather-balloon soundings from the University of Wyoming’s archive (the soundings page).nomads: NOAA’s GFS and RAP forecasts as GRIB2 cuts from NOMADS (the NOAA forecasts page).elevation: a site’s ground height from Open-Meteo (the elevation page).motor_finder: motor stock and prices from motor.fusionspace.co (the motor stock page).thrustcurve: motor records and thrust curves from ThrustCurve.org, matched to the motors in stock (the same page).on_demandfinds one motor there by name, for a simulator that lacks its curve.
This crate does network and file I/O, so it’s never a dependency of the pure core. A
Client asks a Transport for a URL’s bytes only when it’s Mode::Online and its
Cache holds no fresh copy. In Mode::Offline it never calls the transport. It answers
from the cache, stale or not, and says which. The http feature adds Http, the transport
over HTTP and HTTPS (rustls, no OpenSSL). Cache::platform_dir names the platform’s usual
cache folder.
use hpr_net::{Cache, Client, Freshness, Mode, NetError, Source, Transport};
/// A transport that answers every URL with the same bytes.
struct Canned;
impl Transport for Canned {
fn get(&self, _url: &str) -> Result<Vec<u8>, String> {
Ok(b"42".to_vec())
}
}
let dir = std::env::temp_dir().join(format!("hpr-net-doc-{}", std::process::id()));
let source = Source {
name: "Example".into(),
attribution: "Example data".into(),
ttl_s: 3600,
};
let url = "https://example.test/x";
let online = Client::new(Canned, Cache::new(&dir), Mode::Online);
assert_eq!(online.fetch(&source, url, 1_000)?.freshness, Freshness::Fetched);
let offline = Client::new(Canned, Cache::new(&dir), Mode::Offline);
let later = offline.fetch(&source, url, 1_000 + 7_200)?;
assert_eq!((later.freshness, later.body.as_slice()), (Freshness::Stale, &b"42"[..]));Modules§
- catalog_
update - The solid motors and data files ThrustCurve.org lists that the
bundled catalog lacks (M5.7d,
hpr motors update; ADR-288 §4). - elevation
- A launch site’s elevation (height above sea level) from Open-Meteo’s elevation API.
- motor_
finder - Motor stock and prices from motor.fusionspace.co’s public API.
- nomads
- Weather from NOAA’s GFS and RAP forecasts: a small GRIB2 cut from NOMADS’ grib filter around a
launch site, turned into a
SoundingProfile. - on_
demand - One motor found by name on ThrustCurve.org, with the curve file to fly it by: for a simulator that lacks the motor’s curve (M4.5b, motors on demand; ADR-154, the decision on fetching them).
- open_
meteo - Weather from Open-Meteo: a launch site’s forecast (or a past day’s archived forecast) on
pressure levels, turned into a
SoundingProfile. - thrustcurve
- Motor records and thrust curves from ThrustCurve.org’s API, and the join that gives a motor in stock its curve.
- wyoming
- Weather-balloon soundings from the University of Wyoming’s radiosonde archive, turned into a
SoundingProfile.
Structs§
- Cache
- A directory of cached responses, keyed by URL.
- Cache
Entry - What the cache knows about one URL.
- Client
- A cache in front of a transport.
- Fetched
- A body and where it came from.
- Http
- A
Transportthat fetches over HTTP and HTTPS, behind the crate’shttpfeature. - Http
Config - How an
Httptransport behaves. Start fromHttpConfig::defaultand change fields. - Replay
- A transport that replays recorded responses from a directory, for tests and offline demos.
- Source
- One online data source: its name, the credit its terms ask for, and how long a copy stays fresh.
Enums§
- Freshness
- How a
Fetchedbody relates to its source. - Mode
- Whether the client may use the network.
- NetError
- Why a fetch failed.
Constants§
- SOCKS_
REFUSED - The words a
Transport::getrefusal holds when the environment’s proxy is SOCKS, which this transport doesn’t speak:reason.contains(SOCKS_REFUSED)tells that refusal from a failed connection.