Struct rust_release_artefact::Component [] [src]

pub struct Component {
    pub root: PathBuf,
    pub files: BTreeSet<PathBuf>,
}

An installable component of an artefact.

A Component describes a subset of the files in an ExtractedArtefact, which you may want to install in a target location. For example, in order to compile Rust programs, you will need to install all the files of both the rustc (compiler) and rust-std (standard library) components into the same location.

A Component does not store all the relevant files itself, but just their paths inside the ExtractedArtefact's staging area. Therefore, if you want to use the files described by a Component, you must ensure the staging area is not cleaned up before you use them.

Example

extern crate rust_release_artefact as rra;

use std::fs;
use std::io;
use std::path;
use std::process;

// Assume we have an artefact containing a Cargo component.
let cargo = extracted_artefact.components
    .get("cargo")
    .ok_or("Artefact does not contain cargo component")?;

// Make sure our destination exists.
let dest_root = path::Path::new("path/to/my/rust/toolchain");
fs::create_dir_all(&dest_root)?;

// Canonicalize our destination path, so Windows can handle long path
// names.
let dest_root = dest_root.canonicalize()?;

// Install it to our target location.
cargo.install_to(&dest_root)?;

// Now we should be able to run Cargo.
process::Command::new(dest_root.join("bin/cargo"))
    .arg("build")
    .arg("--release")
    .spawn()?;

Fields

The absolute filesystem path to the directory containing all the files in the component.

Relative paths from root to each file in the component.

When installing this component, place each file at the same relative path inside the destination directory.

Methods

impl Component
[src]

[src]

Install this component's files into the destination directory.

dest_root should be a writable directory, or a path at which a writable directory may be created.

For each relative path in self.files, this method constructs a source path by joining it to self.root, a destination path by joining it to dest_root, and then installs the file at the source path to the destination.

To increase performance and reduce disk-space usage, this method will attempt to hard-link files rather than copying them. If hard-linking a file is not possible, it will be copied instead.

Errors

This method will return an error if dest_root or a directory within it could not be created, if a destination file already exists and could not be removed, or if a file could not be copied.

Portability

Components may include a deeply-nested directory structure, which can exceed Windows' traditional 260 character limit. It is recommended that you use canonicalize dest_root before passing it to this method, since the Windows canonical form lifts the path length limit to around 32,000 characters.

Example

See the Component documentation.

Trait Implementations

impl Clone for Component
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for Component
[src]

[src]

Formats the value using the given formatter. Read more

impl Hash for Component
[src]

[src]

Feeds this value into the given [Hasher]. Read more

1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl PartialEq for Component
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl Eq for Component
[src]

impl PartialOrd for Component
[src]

[src]

This method returns an ordering between self and other values if one exists. Read more

[src]

This method tests less than (for self and other) and is used by the < operator. Read more

[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Ord for Component
[src]

[src]

This method returns an Ordering between self and other. Read more

1.21.0
[src]

Compares and returns the maximum of two values. Read more

1.21.0
[src]

Compares and returns the minimum of two values. Read more

Auto Trait Implementations

impl Send for Component

impl Sync for Component