pub struct LocalManifest {
    pub path: PathBuf,
    pub manifest: Manifest,
}
Expand description

A Cargo manifest that is available locally.

Fields

path: PathBuf

Path to the manifest

manifest: Manifest

Manifest 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.

Write changes back to the file

Instruct this manifest to upgrade a single dependency. If this manifest does not have that dependency, it does nothing.

Lookup a dependency

Returns all dependencies

Lookup a dependency

Add entry to a Cargo.toml.

source

pub fn update_table_entry(
    &mut self,
    table_path: &[String],
    dep: &Dependency,
    dry_run: bool
) -> CargoResult<()>

Update an entry in Cargo.toml.

source

pub fn update_table_named_entry(
    &mut self,
    table_path: &[String],
    dep_key: &str,
    dep: &Dependency,
    dry_run: bool
) -> CargoResult<()>

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.contains_key("dependencies"));

Add multiple dependencies to manifest

Allow mutating depedencies, wherever they live

Override the manifest’s version

Remove references to dep_key if its no longer present

Methods from Deref<Target = Manifest>

Get the manifest’s package name

Get the specified table from the manifest.

Get the specified table from the manifest.

Get all sections in the manifest that exist and might contain dependencies. The returned items are always Table or InlineTable.

returns features exposed by this manifest

Trait Implementations

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.