[][src]Struct cargo_edit::Manifest

pub struct Manifest {
    pub data: Document,
}

A Cargo manifest

Fields

data: Document

Manifest contents as TOML data

Methods

impl Manifest[src]

pub fn find_file(path: &Option<PathBuf>) -> Result<File>[src]

Look for a Cargo.toml file

Starts at the given path an goes into its parent directories until the manifest file is found. If no path is given, the process's working directory is used as a starting point.

pub fn open(path: &Option<PathBuf>) -> Result<Manifest>[src]

Open the Cargo.toml for a path (or the process' cwd)

pub fn get_table<'a>(
    &'a mut self,
    table_path: &[String]
) -> Result<&'a mut Item>
[src]

Get the specified table from the manifest.

pub fn get_sections(&self) -> Vec<(Vec<String>, Item)>[src]

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

pub fn write_to_file(&self, file: &mut File) -> Result<()>[src]

Overwrite a file with TOML data.

pub fn insert_into_table(
    &mut self,
    table_path: &[String],
    dep: &Dependency
) -> Result<()>
[src]

Add entry to a Cargo.toml.

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

Update an entry in Cargo.toml.

pub fn remove_from_table(&mut self, table: &str, name: &str) -> Result<()>[src]

Remove entry from a Cargo.toml.

Examples

    use cargo_edit::{Dependency, Manifest};
    use toml_edit;

    let mut 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());

pub fn add_deps(&mut self, table: &[String], deps: &[Dependency]) -> Result<()>[src]

Add multiple dependencies to manifest

Trait Implementations

impl Clone for Manifest[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Manifest[src]

impl FromStr for Manifest[src]

type Err = Error

The associated error which can be returned from parsing.

fn from_str(input: &str) -> Result<Self, Self::Err>[src]

Read manifest data from string

Auto Trait Implementations

impl Send for Manifest

impl Sync for Manifest

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Erased for T

impl<'a, T> TryFrom<&'a str> for T where
    T: FromStr

type Err = <T as FromStr>::Err

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Err = <U as TryFrom<T>>::Err