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
sourceimpl Toolchain
impl Toolchain
sourcepub fn is_needed_by_rustwide(&self) -> bool
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());
sourcepub fn dist(name: &str) -> Self
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).
sourcepub fn ci(sha: &str, alt: bool) -> Self
Available on crate feature unstable-toolchain-ci
only.
pub fn ci(sha: &str, alt: bool) -> Self
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!
sourcepub fn as_dist(&self) -> Option<&DistToolchain>
pub fn as_dist(&self) -> Option<&DistToolchain>
If this toolchain is a dist toolchain, return its metadata.
sourcepub fn as_ci(&self) -> Option<&CiToolchain>
Available on crate feature unstable-toolchain-ci
only.
pub fn as_ci(&self) -> Option<&CiToolchain>
unstable-toolchain-ci
only.If this toolchain is a CI toolchain, return its metadata.
sourcepub fn install(&self, workspace: &Workspace) -> Result<(), Error>
pub fn install(&self, workspace: &Workspace) -> Result<(), Error>
Download and install the toolchain.
sourcepub fn add_component(
&self,
workspace: &Workspace,
name: &str
) -> Result<(), Error>
pub fn add_component(
&self,
workspace: &Workspace,
name: &str
) -> Result<(), Error>
Download and install a component for the toolchain.
sourcepub fn remove_component(
&self,
workspace: &Workspace,
name: &str
) -> Result<(), Error>
pub fn remove_component(
&self,
workspace: &Workspace,
name: &str
) -> Result<(), Error>
Remove a component already installed for the toolchain.
sourcepub fn add_target(&self, workspace: &Workspace, name: &str) -> Result<(), Error>
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.
sourcepub fn remove_target(
&self,
workspace: &Workspace,
name: &str
) -> Result<(), Error>
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.
sourcepub fn installed_targets(
&self,
workspace: &Workspace
) -> Result<Vec<String>, Error>
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.
sourcepub fn uninstall(&self, workspace: &Workspace) -> Result<(), Error>
pub fn uninstall(&self, workspace: &Workspace) -> Result<(), Error>
Remove the toolchain from the rustwide workspace, freeing up disk space.
sourcepub fn cargo(&self) -> impl Runnable + '_
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()?;
sourcepub fn rustc(&self) -> impl Runnable + '_
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()?;
sourcepub fn rustup_binary(&self, name: &'static str) -> impl Runnable + '_
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
sourceimpl<'de> Deserialize<'de> for Toolchain
impl<'de> Deserialize<'de> for Toolchain
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Toolchain
impl StructuralEq for Toolchain
impl StructuralPartialEq for Toolchain
Auto Trait Implementations
impl RefUnwindSafe for Toolchain
impl Send for Toolchain
impl Sync for Toolchain
impl Unpin for Toolchain
impl UnwindSafe for Toolchain
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more