Skip to main content

Crate node_js_release_info

Crate node_js_release_info 

Source
Expand description

§node-js-release-info

Latest Version Documentation CI Status

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 full
use 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 json
use 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

beforeafter
NodeJSRelInfoNodeJsRelInfo
NodeJSRelInfoErrorNodeJsRelInfoError
NodeJSOSNodeJsOs
NodeJSArchNodeJsArch
NodeJSPkgExtNodeJsPkgExt
NodeJSOS::AIXNodeJsOs::Aix
NodeJSArch::ARM64NodeJsArch::Arm64
NodeJSArch::ARMV7LNodeJsArch::Armv7l
NodeJSArch::PPC64NodeJsArch::Ppc64
NodeJSArch::PPC64LENodeJsArch::Ppc64le
NodeJSArch::S390XNodeJsArch::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§

NodeJsRelInfo
Metadata describing a single Node.js distributable

Enums§

NodeJsArch
The CPU architecture a Node.js distributable targets
NodeJsOs
The operating system a Node.js distributable targets
NodeJsPkgExt
The file extension of a Node.js distributable
NodeJsRelInfoError
The error type returned by all fallible operations in this crate