Struct cargo_edit::LocalManifest[][src]

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.

Add entry to a Cargo.toml.

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<()>

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)

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.

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

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

Performs the conversion.

Performs the conversion.

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.