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 */
}

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("20.6.1");
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("20.6.1");
Source

pub fn macos(&mut self) -> &mut Self

Sets instance os field to darwin

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

pub fn linux(&mut self) -> &mut Self

Sets instance os field to linux

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

pub fn windows(&mut self) -> &mut Self

Sets instance os field to windows

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

pub fn aix(&mut self) -> &mut Self

Sets instance os field to aix

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

pub fn x64(&mut self) -> &mut Self

Sets instance arch field to x64

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

pub fn x86(&mut self) -> &mut Self

Sets instance arch field to x86

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

pub fn arm64(&mut self) -> &mut Self

Sets instance arch field to arm64

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

pub fn armv7l(&mut self) -> &mut Self

Sets instance arch field to armv7l

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

pub fn ppc64(&mut self) -> &mut Self

Sets instance arch field to ppc64

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

pub fn ppc64le(&mut self) -> &mut Self

Sets instance arch field to ppc64le

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

pub fn s390x(&mut self) -> &mut Self

Sets instance arch field to s390x

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

pub fn tar_gz(&mut self) -> &mut Self

Sets instance ext field to tar.gz

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

pub fn tar_xz(&mut self) -> &mut Self

Sets instance ext field to tar.xz

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

pub fn zip(&mut self) -> &mut Self

Sets instance ext field to zip

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

pub fn s7z(&mut self) -> &mut Self

Sets instance ext field to 7z

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

pub fn msi(&mut self) -> &mut Self

Sets instance ext field to msi

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

pub fn to_owned(&self) -> Self

Creates owned data from reference for convenience when chaining

§Examples
use node_js_release_info::NodeJSRelInfo;
let info = NodeJSRelInfo::new("20.6.1").windows().x64().zip().to_owned();
Source

pub async fn fetch(&mut self) -> Result<Self, NodeJSRelInfoError>

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

§Examples
use node_js_release_info::{NodeJSRelInfo, NodeJSRelInfoError};

#[tokio::main]
async fn main() -> Result<(), NodeJSRelInfoError> {
  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");
  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("20.6.1");
  let all = info.fetch_all().await?;
  assert_eq!(all.len(), 24);
  assert_eq!(all[2].version, "20.6.1");
  assert_eq!(all[2].filename, "node-v20.6.1-darwin-arm64.tar.gz");
  assert_eq!(all[2].sha256, "d8ba8018d45b294429b1a7646ccbeaeb2af3cdf45b5c91dabbd93e2a2035cb46");
  assert_eq!(all[2].url, "https://nodejs.org/download/release/v20.6.1/node-v20.6.1-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 · 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 PartialEq for NodeJSRelInfo

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
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> 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> 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
Source§

impl<T> ErasedDestructor for T
where T: 'static,