pub struct Toolchain { /* private fields */ }
Expand description

Representation of a Rust compiler toolchain.

The Toolchain struct represents a compiler toolchain, either downloaded from rustup or from the rust-lang/rust repo’s CI artifacts storage, and it provides the methods to install and use it.

Implementations§

source§

impl Toolchain

source

pub fn is_needed_by_rustwide(&self) -> bool

Returns whether or not this toolchain is needed by rustwide itself.

This toolchain is used for doing things like installing tools.

let tc = Toolchain::dist("stable-x86_64-unknown-linux-gnu");
assert!(tc.is_needed_by_rustwide());
let tc = Toolchain::dist("nightly-x86_64-unknown-linux-gnu");
assert!(!tc.is_needed_by_rustwide());
source

pub fn dist(name: &str) -> Self

Create a new dist toolchain.

Dist toolchains are all the toolchains available through rustup and distributed from static.rust-lang.org. You need to provide the toolchain name (the same you’d use to install that toolchain with rustup).

source

pub fn ci(sha: &str, alt: bool) -> Self

Available on crate feature unstable-toolchain-ci only.

Create a new CI toolchain.

CI toolchains are artifacts built for every merged PR in the rust-lang/rust repository, identified by the SHA of the merge commit. These builds are purged after a couple of months, and are available both in normal mode and “alternate” mode (experimental builds with extra debugging and testing features enabled).

There is no availability or stability guarantee for these builds!

source

pub fn as_dist(&self) -> Option<&DistToolchain>

If this toolchain is a dist toolchain, return its metadata.

source

pub fn as_ci(&self) -> Option<&CiToolchain>

Available on crate feature unstable-toolchain-ci only.

If this toolchain is a CI toolchain, return its metadata.

source

pub fn install(&self, workspace: &Workspace) -> Result<(), Error>

Download and install the toolchain.

source

pub fn add_component( &self, workspace: &Workspace, name: &str ) -> Result<(), Error>

Download and install a component for the toolchain.

source

pub fn remove_component( &self, workspace: &Workspace, name: &str ) -> Result<(), Error>

Remove a component already installed for the toolchain.

source

pub fn add_target(&self, workspace: &Workspace, name: &str) -> Result<(), Error>

Download and install a target for the toolchain.

If the toolchain is not installed in the workspace an error will be returned. This is only supported for dist toolchains.

source

pub fn remove_target( &self, workspace: &Workspace, name: &str ) -> Result<(), Error>

Remove a target already installed for the toolchain.

If the toolchain is not installed in the workspace or the target is missing an error will be returned. This is only supported for dist toolchains.

source

pub fn installed_targets( &self, workspace: &Workspace ) -> Result<Vec<String>, Error>

Return a list of installed targets for this toolchain.

If the toolchain is not installed an empty list is returned.

source

pub fn uninstall(&self, workspace: &Workspace) -> Result<(), Error>

Remove the toolchain from the rustwide workspace, freeing up disk space.

source

pub fn cargo(&self) -> impl Runnable + '_

Return a runnable object configured to run cargo with this toolchain. This method is intended to be used with rustwide::cmd::Command.

Example
let toolchain = Toolchain::dist("beta");
Command::new(&workspace, toolchain.cargo())
    .args(&["check"])
    .run()?;
source

pub fn rustc(&self) -> impl Runnable + '_

Return a runnable object configured to run rustc with this toolchain. This method is intended to be used with rustwide::cmd::Command.

Example
let toolchain = Toolchain::dist("beta");
Command::new(&workspace, toolchain.rustc())
    .args(&["hello.rs"])
    .run()?;
source

pub fn rustup_binary(&self, name: &'static str) -> impl Runnable + '_

Return a runnable object configured to run name with this toolchain. This method is intended to be used with rustwide::cmd::Command.

Example
let toolchain = Toolchain::dist("beta");
Command::new(&workspace, toolchain.rustup_binary("rustdoc"))
    .args(&["hello.rs"])
    .run()?;

Trait Implementations§

source§

impl Clone for Toolchain

source§

fn clone(&self) -> Toolchain

Returns a copy 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 Toolchain

source§

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

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

impl<'de> Deserialize<'de> for Toolchain

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 Display for Toolchain

source§

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

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

impl Hash for Toolchain

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<Toolchain> for Toolchain

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Toolchain

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 Eq for Toolchain

source§

impl StructuralEq for Toolchain

source§

impl StructuralPartialEq for Toolchain

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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 Twhere T: Clone,

§

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> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,