pub struct PackageIndexClient { /* private fields */ }Expand description
A typed client over the ZLayer package index.
Cheap to construct and clone-free per call; the inner reqwest::Client
follows redirects by default (the index answers /formula/:name with a 302
to the cached artifact host for some routes).
Implementations§
Source§impl PackageIndexClient
impl PackageIndexClient
Sourcepub fn new(config: PackageIndexConfig) -> Self
pub fn new(config: PackageIndexConfig) -> Self
Build a client from an explicit PackageIndexConfig. Infallible: a
reqwest::Client build error falls back to reqwest::Client::default.
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Build a client honoring ZLAYER_PACKAGE_INDEX_URL (default
https://packages.zlayer.dev).
Sourcepub async fn get_formula(&self, name: &str) -> Result<FormulaData>
pub async fn get_formula(&self, name: &str) -> Result<FormulaData>
Fetch and parse a formula from {base_url}/formula/{name}.
Fallback chain: the index first; on an explicit miss (404) fire a
best-effort HMAC refresh hint and retry once; on any remaining
miss/failure fall back to the direct formulae.brew.sh upstream.
§Errors
Returns ToolchainError::RegistryError only when neither the index nor
the upstream can produce a parseable formula.