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
root: PathBuf
The absolute filesystem path to the directory containing all the files in the component.
files: BTreeSet<PathBuf>
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]
pub fn install_to<P: AsRef<Path>>(&self, dest_root: P) -> Result<()>
[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]
fn clone(&self) -> Component
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for Component
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Hash for Component
[src]
fn hash<__H: Hasher>(&self, __arg_0: &mut __H)
[src]
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl PartialEq for Component
[src]
fn eq(&self, __arg_0: &Component) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Component) -> bool
[src]
This method tests for !=
.
impl Eq for Component
[src]
impl PartialOrd for Component
[src]
fn partial_cmp(&self, __arg_0: &Component) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &Component) -> bool
[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &Component) -> bool
[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, __arg_0: &Component) -> bool
[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &Component) -> bool
[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]
fn cmp(&self, __arg_0: &Component) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more