Skip to main content

NodeJsRelInfo

Struct NodeJsRelInfo 

Source
pub struct NodeJsRelInfo {
    pub os: NodeJsOs,
    pub arch: NodeJsArch,
    pub ext: NodeJsPkgExt,
    pub version: String,
    pub filename: String,
    pub sha256: String,
    pub url: String,
    /* private fields */
}
Expand description

Metadata describing a single Node.js distributable

Build one with new or from_env, narrow it with the builder methods (e.g. macos, arm64), then call fetch to populate filename, sha256 and url from the downloads server

Fields§

§os: NodeJsOs

The operating system for the Node.js distributable you are targeting

§arch: NodeJsArch

The CPU architecture for the Node.js distributable you are targeting

§ext: NodeJsPkgExt

The file extension for the Node.js distributable you are targeting

§version: String

The version of Node.js you are targeting as a semver string

§filename: String

The filename of the Node.js distributable (populated after fetching)

§sha256: String

The hash for the Node.js distributable (populated after fetching)

§url: String

The fully qualified url for the Node.js distributable (populated after fetching)

Implementations§

Source§

impl NodeJsRelInfo

Source

pub fn new<T: AsRef<str>>(semver: T) -> Self

Creates a new instance using default settings

§Arguments
  • semver - The Node.js version you are targeting (String / &str)
§Examples
use node_js_release_info::NodeJsRelInfo;
let info = NodeJsRelInfo::new("24.19.0");
Source

pub fn from_env<T: AsRef<str>>( semver: T, ) -> Result<NodeJsRelInfo, NodeJsRelInfoError>

Creates a new instance mirroring current environment based on std::env::consts::OS and std::env::consts::ARCH

§Arguments
  • semver - The Node.js version you are targeting (String / &str)
§Examples
use node_js_release_info::NodeJsRelInfo;
let info = NodeJsRelInfo::from_env("24.19.0");
Source

pub fn macos(self) -> Self

Sets instance os field to darwin

§Examples
use node_js_release_info::NodeJsRelInfo;
let info = NodeJsRelInfo::new("24.19.0").macos();
Source

pub fn linux(self) -> Self

Sets instance os field to linux

§Examples
use node_js_release_info::NodeJsRelInfo;
let info = NodeJsRelInfo::new("24.19.0").linux();
Source

pub fn windows(self) -> Self

Sets instance os field to windows

§Examples
use node_js_release_info::NodeJsRelInfo;
let info = NodeJsRelInfo::new("24.19.0").windows();
Source

pub fn aix(self) -> Self

Sets instance os field to aix

§Examples
use node_js_release_info::NodeJsRelInfo;
let info = NodeJsRelInfo::new("24.19.0").aix();
Source

pub fn x64(self) -> Self

Sets instance arch field to x64

§Examples
use node_js_release_info::NodeJsRelInfo;
let info = NodeJsRelInfo::new("24.19.0").x64();
Source

pub fn x86(self) -> Self

Sets instance arch field to x86

§Examples
use node_js_release_info::NodeJsRelInfo;
let info = NodeJsRelInfo::new("24.19.0").x86();
Source

pub fn arm64(self) -> Self

Sets instance arch field to arm64

§Examples
use node_js_release_info::NodeJsRelInfo;
let info = NodeJsRelInfo::new("24.19.0").arm64();
Source

pub fn armv7l(self) -> Self

Sets instance arch field to armv7l

§Examples
use node_js_release_info::NodeJsRelInfo;
let info = NodeJsRelInfo::new("24.19.0").armv7l();
Source

pub fn ppc64(self) -> Self

Sets instance arch field to ppc64

§Examples
use node_js_release_info::NodeJsRelInfo;
let info = NodeJsRelInfo::new("24.19.0").ppc64();
Source

pub fn ppc64le(self) -> Self

Sets instance arch field to ppc64le

§Examples
use node_js_release_info::NodeJsRelInfo;
let info = NodeJsRelInfo::new("24.19.0").ppc64le();
Source

pub fn s390x(self) -> Self

Sets instance arch field to s390x

§Examples
use node_js_release_info::NodeJsRelInfo;
let info = NodeJsRelInfo::new("24.19.0").s390x();
Source

pub fn tar_gz(self) -> Self

Sets instance ext field to tar.gz

§Examples
use node_js_release_info::NodeJsRelInfo;
let info = NodeJsRelInfo::new("24.19.0").tar_gz();
Source

pub fn tar_xz(self) -> Self

Sets instance ext field to tar.xz

§Examples
use node_js_release_info::NodeJsRelInfo;
let info = NodeJsRelInfo::new("24.19.0").tar_xz();
Source

pub fn zip(self) -> Self

Sets instance ext field to zip

§Examples
use node_js_release_info::NodeJsRelInfo;
let info = NodeJsRelInfo::new("24.19.0").zip();
Source

pub fn s7z(self) -> Self

Sets instance ext field to 7z

§Examples
use node_js_release_info::NodeJsRelInfo;
let info = NodeJsRelInfo::new("24.19.0").s7z();
Source

pub fn msi(self) -> Self

Sets instance ext field to msi

§Examples
use node_js_release_info::NodeJsRelInfo;
let info = NodeJsRelInfo::new("24.19.0").msi();
Source

pub async fn fetch(self) -> Result<Self, NodeJsRelInfoError>

Creates owned data from reference for convenience when chaining

Fetches Node.js metadata for specified configuration from the releases download server

§Errors

Returns InvalidVersion when version is not valid semver, UnrecognizedVersion when the release does not exist, UnrecognizedConfiguration when the release exists but ships no such os/arch/ext combination, and HttpError when the request fails

§Examples
use node_js_release_info::{NodeJsRelInfo, NodeJsRelInfoError};

#[tokio::main]
async fn main() -> Result<(), NodeJsRelInfoError> {
  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");
  Ok(())
}
Source

pub async fn fetch_all(&self) -> Result<Vec<NodeJsRelInfo>, NodeJsRelInfoError>

Fetches Node.js metadata for all supported configurations from the releases download server

§Examples
use node_js_release_info::{NodeJsRelInfo, NodeJsRelInfoError};

#[tokio::main]
async fn main() -> Result<(), NodeJsRelInfoError> {
  let info = NodeJsRelInfo::new("24.19.0");
  let all = info.fetch_all().await?;
  assert_eq!(all.len(), 19);
  assert_eq!(all[2].version, "24.19.0");
  assert_eq!(all[2].filename, "node-v24.19.0-darwin-arm64.tar.gz");
  assert_eq!(all[2].sha256, "8294b7aa9b03997481c06babf1e8b270c859358f27da57a11509afe537ac381d");
  assert_eq!(all[2].url, "https://nodejs.org/download/release/v24.19.0/node-v24.19.0-darwin-arm64.tar.gz");
  Ok(())
}

Trait Implementations§

Source§

impl Clone for NodeJsRelInfo

Source§

fn clone(&self) -> NodeJsRelInfo

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for NodeJsRelInfo

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for NodeJsRelInfo

Source§

fn default() -> NodeJsRelInfo

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for NodeJsRelInfo

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for NodeJsRelInfo

Source§

impl Hash for NodeJsRelInfo

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for NodeJsRelInfo

Source§

fn eq(&self, other: &NodeJsRelInfo) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for NodeJsRelInfo

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for NodeJsRelInfo

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more