Expand description
§node-js-release-info
Asynchronously retrieve Node.js release info by version and platform from the downloads server
§Installation
cargo add node-js-release-info§Examples
This example uses Tokio, be sure to install it with:
cargo add tokio --features fulluse node_js_release_info::{NodeJsRelInfo, NodeJsRelInfoError};
#[tokio::main]
async fn main() -> Result<(), NodeJsRelInfoError> {
// get a specific configuration
let info = NodeJsRelInfo::new("24.19.0").macos().arm64().fetch().await?;
assert_eq!(info.version, "24.19.0");
assert_eq!(info.filename, "node-v24.19.0-darwin-arm64.tar.gz");
assert_eq!(info.sha256, "8294b7aa9b03997481c06babf1e8b270c859358f27da57a11509afe537ac381d");
assert_eq!(info.url, "https://nodejs.org/download/release/v24.19.0/node-v24.19.0-darwin-arm64.tar.gz");
// get all supported configurations
let all = info.fetch_all().await?;
assert_eq!(all.len(), 19);
assert_eq!(all[2], info);
println!("{:?}", all);
Ok(())
}§Features
Full json serialization + deserialization is available via the json feature.
cargo add node-js-release-info --features jsonuse node_js_release_info::NodeJsRelInfo;
#[tokio::main]
async fn main() {
let info = NodeJsRelInfo::new("24.19.0").macos().arm64();
let json = serde_json::to_string(&info).unwrap();
let info_deserialized = serde_json::from_str(&json).unwrap();
assert_eq!(info, info_deserialized);
}§Migrations
1.x -> 2.x
Type and variant names now follow RFC 430
| before | after |
|---|---|
NodeJSRelInfo | NodeJsRelInfo |
NodeJSRelInfoError | NodeJsRelInfoError |
NodeJSOS | NodeJsOs |
NodeJSArch | NodeJsArch |
NodeJSPkgExt | NodeJsPkgExt |
NodeJSOS::AIX | NodeJsOs::Aix |
NodeJSArch::ARM64 | NodeJsArch::Arm64 |
NodeJSArch::ARMV7L | NodeJsArch::Armv7l |
NodeJSArch::PPC64 | NodeJsArch::Ppc64 |
NodeJSArch::PPC64LE | NodeJsArch::Ppc64le |
NodeJSArch::S390X | NodeJsArch::S390x |
Builder methods consume self
They now return an owned value directly, so the trailing to_owned() is no longer needed - and NodeJsRelInfo::to_owned() has been removed. Use .clone() if you want a copy.
// before
let info = NodeJSRelInfo::new("24.19.0").macos().arm64().to_owned();
// after
let info = NodeJsRelInfo::new("24.19.0").macos().arm64();Calling a builder as a statement no longer works, since it takes self:
// before
let mut info = NodeJSRelInfo::new("24.19.0");
info.macos();
// after
let info = NodeJsRelInfo::new("24.19.0").macos();fetch() consumes self
It previously mutated in place and returned a clone. It now takes self and returns the populated value:
// before
let mut info = NodeJSRelInfo::new("24.19.0");
info.fetch().await?; // `info` updated in place
// after
let info = NodeJsRelInfo::new("24.19.0").fetch().await?;Enums are #[non_exhaustive]
NodeJsOs, NodeJsArch, NodeJsPkgExt and NodeJsRelInfoError may gain variants in a minor release, so a match over them needs a _ arm. Node.js adds and removes target platforms over time, and this keeps that from being a breaking change.
Error messages changed
The Error: prefix is gone and messages are lowercased, per API guideline C-GOOD-ERR. Previously they composed into chains as Error: Error: ....
before: Error: Invalid Version! Received: 'x'
after: invalid version - received: 'x'NodeJsRelInfoError also implements Error::source() now, exposing the underlying reqwest::Error behind HttpError.
New variants
NodeJsOs::SunOs (sunos) and NodeJsArch::Armv6l (armv6l) were missing. Both appear in older Node.js releases, so fetching those versions previously failed with UnrecognizedOs / UnrecognizedArch on valid artifacts.
Note that Node.js v24 dropped linux-armv7l and all 32-bit Windows builds, so fetch_all returns 19 configurations for v24 where v20 returned 24.
Structs§
- Node
JsRel Info - Metadata describing a single Node.js distributable
Enums§
- Node
JsArch - The CPU architecture a Node.js distributable targets
- Node
JsOs - The operating system a Node.js distributable targets
- Node
JsPkg Ext - The file extension of a Node.js distributable
- Node
JsRel Info Error - The error type returned by all fallible operations in this crate