Struct cargo_update::ops::PackageConfig
[−]
[src]
pub struct PackageConfig { pub toolchain: Option<String>, pub default_features: bool, pub features: BTreeSet<String>, pub debug: Option<bool>, }
Compilation configuration for one crate.
Examples
Reading a configset, adding an entry to it, then writing it back.
let mut configuration = PackageConfig::read(&config_file).unwrap(); configuration.insert("cargo_update".to_string(), PackageConfig::from(&operations)); PackageConfig::write(&configuration, &config_file).unwrap();
Fields
toolchain: Option<String>
Toolchain to use to compile the package, or None
for default.
default_features: bool
Whether to compile the package with the default features.
features: BTreeSet<String>
Features to compile the package with.
debug: Option<bool>
Whether to compile in debug mode.
Methods
impl PackageConfig
[src]
fn from<'o, O: IntoIterator<Item = &'o ConfigOperation>>(
ops: O
) -> PackageConfig
[src]
ops: O
) -> PackageConfig
Create a package config based on the default settings and modified according to the specified operations.
Examples
assert_eq!(PackageConfig::from(&[ConfigOperation::SetToolchain("nightly".to_string()), ConfigOperation::DefaultFeatures(false), ConfigOperation::AddFeature("rustc-serialize".to_string()), ConfigOperation::SetDebugMode(true)]), PackageConfig { toolchain: Some("nightly".to_string()), default_features: false, features: { let mut feats = BTreeSet::new(); feats.insert("rustc-serialize".to_string()); feats }, debug: Some(true), });
fn cargo_args(&self) -> Vec<String>
[src]
Generate cargo arguments from this configuration.
Examples
let cmd = Command::new("cargo").args(configuration.get(&name).unwrap().cargo_args()).arg(&name) // Process the command further -- run it, for example.
fn execute_operations<'o, O: IntoIterator<Item = &'o ConfigOperation>>(
&mut self,
ops: O
)
[src]
&mut self,
ops: O
)
Modify self
according to the specified set of operations.
Examples
let mut cfg = PackageConfig { toolchain: Some("nightly".to_string()), default_features: false, features: { let mut feats = BTreeSet::new(); feats.insert("rustc-serialize".to_string()); feats }, debug: None, }; cfg.execute_operations(&[ConfigOperation::RemoveToolchain, ConfigOperation::AddFeature("serde".to_string()), ConfigOperation::RemoveFeature("rustc-serialize".to_string()), ConfigOperation::SetDebugMode(true)]); assert_eq!(cfg, PackageConfig { toolchain: None, default_features: false, features: { let mut feats = BTreeSet::new(); feats.insert("serde".to_string()); feats }, debug: Some(true) });
fn read(p: &Path) -> Result<BTreeMap<String, PackageConfig>, i32>
[src]
Read a configset from the specified file.
If the specified file doesn't exist an empty configset is returned.
Examples
File::create(&config_file).unwrap().write_all(&b"\ [cargo-update]\n\ default_features = true\n\ features = [\"serde\"]\n"[..]); assert_eq!(PackageConfig::read(&config_file), Ok({ let mut pkgs = BTreeMap::new(); pkgs.insert("cargo-update".to_string(), PackageConfig { toolchain: None, default_features: true, features: { let mut feats = BTreeSet::new(); feats.insert("serde".to_string()); feats }, debug: None, }); pkgs }));
fn write(
configuration: &BTreeMap<String, PackageConfig>,
p: &Path
) -> Result<(), i32>
[src]
configuration: &BTreeMap<String, PackageConfig>,
p: &Path
) -> Result<(), i32>
Save a configset to the specified file.
Examples
PackageConfig::write(&{ let mut pkgs = BTreeMap::new(); pkgs.insert("cargo-update".to_string(), PackageConfig { toolchain: None, default_features: true, features: { let mut feats = BTreeSet::new(); feats.insert("serde".to_string()); feats }, debug: None, }); pkgs }, &config_file).unwrap(); let mut buf = String::new(); File::open(&config_file).unwrap().read_to_string(&mut buf).unwrap(); assert_eq!(&buf, "[cargo-update]\n\ default_features = true\n\ features = [\"serde\"]\n");
Trait Implementations
impl Debug for PackageConfig
[src]
impl Clone for PackageConfig
[src]
fn clone(&self) -> PackageConfig
[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 Hash for PackageConfig
[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 PackageConfig
[src]
fn eq(&self, __arg_0: &PackageConfig) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &PackageConfig) -> bool
[src]
This method tests for !=
.
impl Eq for PackageConfig
[src]
impl PartialOrd for PackageConfig
[src]
fn partial_cmp(&self, __arg_0: &PackageConfig) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &PackageConfig) -> bool
[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &PackageConfig) -> 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: &PackageConfig) -> bool
[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &PackageConfig) -> 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 PackageConfig
[src]
fn cmp(&self, __arg_0: &PackageConfig) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.22.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.22.0[src]
Compares and returns the minimum of two values. Read more
impl Default for PackageConfig
[src]
fn default() -> PackageConfig
[src]
Returns the "default value" for a type. Read more