Crates.io | node-js-release-info |
lib.rs | node-js-release-info |
version | 1.1.1 |
source | src |
created_at | 2023-09-29 20:08:19.359705 |
updated_at | 2023-10-25 18:46:48.622514 |
description | Asynchronously retrieve Node.js release info by version and platform from the [downloads server](https://nodejs.org/download/release/) |
homepage | |
repository | https://github.com/busticated/rusty |
max_upload_size | |
id | 987832 |
size | 61,211 |
Asynchronously retrieve Node.js release info by version and platform from the downloads server
cargo add node-js-release-info
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("20.6.1").macos().arm64().fetch().await?;
assert_eq!(info.version, "20.6.1");
assert_eq!(info.filename, "node-v20.6.1-darwin-arm64.tar.gz");
assert_eq!(info.sha256, "d8ba8018d45b294429b1a7646ccbeaeb2af3cdf45b5c91dabbd93e2a2035cb46");
assert_eq!(info.url, "https://nodejs.org/download/release/v20.6.1/node-v20.6.1-darwin-arm64.tar.gz");
// get all supported configurations
let all = info.fetch_all().await?;
assert_eq!(all.len(), 24);
assert_eq!(all[2], info);
println!("{:?}", all);
Ok(())
}
Full json
serialization + deserialization is avaialable via the json
feature.
cargo add node-js-release-info --features json
use node_js_release_info::{NodeJSRelInfo, NodeJSRelInfoError};
#[tokio::main]
async fn main() {
let info = NodeJSRelInfo::new("20.6.1").macos().arm64().to_owned();
let json = serde_json::to_string(&info).unwrap();
let info_deserialized = serde_json::from_str(&json).unwrap();
assert_eq!(info, info_deserialized);
}