Struct cargo_edit::LocalManifest [−][src]
Expand description
A Cargo manifest that is available locally.
Fields
path: PathBufPath to the manifest
manifest: ManifestManifest contents
Implementations
Construct a LocalManifest. If no path is provided, make an educated guess as to which one
the user means.
Construct the LocalManifest corresponding to the Path provided.
Instruct this manifest to upgrade a single dependency. If this manifest does not have that dependency, it does nothing.
Add entry to a Cargo.toml.
pub fn update_table_entry(
&mut self,
table_path: &[String],
dep: &Dependency,
dry_run: bool
) -> Result<()>
pub fn update_table_entry(
&mut self,
table_path: &[String],
dep: &Dependency,
dry_run: bool
) -> Result<()>
Update an entry in Cargo.toml.
pub fn update_table_named_entry(
&mut self,
table_path: &[String],
dep_key: &str,
dep: &Dependency,
dry_run: bool
) -> Result<()>
pub fn update_table_named_entry(
&mut self,
table_path: &[String],
dep_key: &str,
dep: &Dependency,
dry_run: bool
) -> Result<()>
Update an entry with a specified name in Cargo.toml.
Remove entry from a Cargo.toml.
Examples
use cargo_edit::{Dependency, LocalManifest, Manifest};
use toml_edit;
let root = std::path::PathBuf::from("/").canonicalize().unwrap();
let path = root.join("Cargo.toml");
let mut manifest = LocalManifest { path, manifest: Manifest { data: toml_edit::Document::new() } };
let dep = Dependency::new("cargo-edit").set_version("0.1.0");
let _ = manifest.insert_into_table(&vec!["dependencies".to_owned()], &dep);
assert!(manifest.remove_from_table("dependencies", &dep.name).is_ok());
assert!(manifest.remove_from_table("dependencies", &dep.name).is_err());
assert!(manifest.data["dependencies"].is_none());Add multiple dependencies to manifest
Find a dependency by name (matching on package name for renamed deps)
pub fn get_dependency_tables_mut<'r>(
&'r mut self
) -> impl Iterator<Item = &mut dyn TableLike> + 'r
pub fn get_dependency_tables_mut<'r>(
&'r mut self
) -> impl Iterator<Item = &mut dyn TableLike> + 'r
Allow mutating depedencies, wherever they live
Override the manifest’s version
Methods from Deref<Target = Manifest>
Get the manifest’s package name
Get the specified table from the manifest.