Struct cargo_edit::Manifest
[−]
[src]
pub struct Manifest { pub data: Table, }
A Cargo Manifest
Fields
data: Table
Manifest contents as TOML data
Methods
impl Manifest
[src]
fn find_file(path: &Option<PathBuf>) -> Result<File, Box<Error>>
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.
fn find_lock_file(path: &Option<PathBuf>) -> Result<File, Box<Error>>
Look for a Cargo.lock
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' working directory is used as a starting point.
fn open(path: &Option<PathBuf>) -> Result<Manifest, Box<Error>>
Open the Cargo.toml
for a path (or the process' cwd
)
fn open_lock_file(path: &Option<PathBuf>) -> Result<Manifest, Box<Error>>
Open the Cargo.lock
for a path (or the process' cwd
)
fn get_table<'a>(
&'a mut self,
table_path: &[String]
) -> Result<&'a mut BTreeMap<String, Value>, ManifestError>
&'a mut self,
table_path: &[String]
) -> Result<&'a mut BTreeMap<String, Value>, ManifestError>
Get the specified table from the manifest.
fn get_sections(&self) -> Vec<(Vec<String>, BTreeMap<String, Value>)>
Get all sections in the manifest that exist and might contain dependencies.
fn write_to_file(&self, file: &mut File) -> Result<(), Box<Error>>
Overwrite a file with TOML data.
fn insert_into_table(
&mut self,
table_path: &[String],
dep: &Dependency
) -> Result<(), ManifestError>
&mut self,
table_path: &[String],
dep: &Dependency
) -> Result<(), ManifestError>
Add entry to a Cargo.toml.
fn update_table_entry(
&mut self,
table_path: &[String],
dep: &Dependency
) -> Result<(), ManifestError>
&mut self,
table_path: &[String],
dep: &Dependency
) -> Result<(), ManifestError>
Update an entry in Cargo.toml.
fn remove_from_table(
&mut self,
table: &str,
name: &str
) -> Result<(), ManifestError>
&mut self,
table: &str,
name: &str
) -> Result<(), ManifestError>
Remove entry from a Cargo.toml.
Examples
use cargo_edit::{Dependency, Manifest}; use toml; let mut manifest = Manifest { data: toml::value::Table::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.is_empty());
fn add_deps(
&mut self,
table: &[String],
deps: &[Dependency]
) -> Result<(), Box<Error>>
&mut self,
table: &[String],
deps: &[Dependency]
) -> Result<(), Box<Error>>
Add multiple dependencies to manifest
Trait Implementations
impl Debug for Manifest
[src]
impl Clone for Manifest
[src]
fn clone(&self) -> Manifest
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl PartialEq for Manifest
[src]
fn eq(&self, __arg_0: &Manifest) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Manifest) -> bool
This method tests for !=
.