[−][src]Struct cargo_update::ops::PackageConfig
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.
install_prereleases: Option<bool>
Whether to install pre-release versions.
target_version: Option<VersionReq>
Versions to constrain to.
Methods
impl PackageConfig
[src]
pub 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), ConfigOperation::SetInstallPrereleases(false), ConfigOperation::SetTargetVersion(VersionReq::from_str(">=0.1").unwrap())]), 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), install_prereleases: Some(false), target_version: Some(VersionReq::from_str(">=0.1").unwrap()), });
pub 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.
pub 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, install_prereleases: None, target_version: Some(VersionReq::from_str(">=0.1").unwrap()), }; cfg.execute_operations(&[ConfigOperation::RemoveToolchain, ConfigOperation::AddFeature("serde".to_string()), ConfigOperation::RemoveFeature("rustc-serialize".to_string()), ConfigOperation::SetDebugMode(true), ConfigOperation::RemoveTargetVersion]); assert_eq!(cfg, PackageConfig { toolchain: None, default_features: false, features: { let mut feats = BTreeSet::new(); feats.insert("serde".to_string()); feats }, debug: Some(true), install_prereleases: None, target_version: None, });
pub 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, install_prereleases: None, target_version: None, }); pkgs }));
pub 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, install_prereleases: None, target_version: 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 Clone for PackageConfig
[src]
fn clone(&self) -> PackageConfig
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for PackageConfig
[src]
impl Default for PackageConfig
[src]
fn default() -> PackageConfig
[src]
impl<'de> Deserialize<'de> for PackageConfig
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Eq for PackageConfig
[src]
impl Hash for PackageConfig
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for PackageConfig
[src]
fn cmp(&self, other: &PackageConfig) -> Ordering
[src]
#[must_use]
fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]
fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]
fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<PackageConfig> for PackageConfig
[src]
fn eq(&self, other: &PackageConfig) -> bool
[src]
fn ne(&self, other: &PackageConfig) -> bool
[src]
impl PartialOrd<PackageConfig> for PackageConfig
[src]
fn partial_cmp(&self, other: &PackageConfig) -> Option<Ordering>
[src]
fn lt(&self, other: &PackageConfig) -> bool
[src]
fn le(&self, other: &PackageConfig) -> bool
[src]
fn gt(&self, other: &PackageConfig) -> bool
[src]
fn ge(&self, other: &PackageConfig) -> bool
[src]
impl Serialize for PackageConfig
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl StructuralEq for PackageConfig
[src]
impl StructuralPartialEq for PackageConfig
[src]
Auto Trait Implementations
impl RefUnwindSafe for PackageConfig
impl Send for PackageConfig
impl Sync for PackageConfig
impl Unpin for PackageConfig
impl UnwindSafe for PackageConfig
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,