Struct cargo_edit::Manifest [−][src]
pub struct Manifest { pub data: Document, }
A Cargo manifest
Fields
data: Document
Manifest contents as TOML data
Methods
impl Manifest
[src]
impl Manifest
pub fn find_file(path: &Option<PathBuf>) -> Result<File>
[src]
pub fn find_file(path: &Option<PathBuf>) -> Result<File>
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]
pub fn open(path: &Option<PathBuf>) -> Result<Manifest>
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]
pub fn get_table<'a>(
&'a mut self,
table_path: &[String]
) -> Result<&'a mut Item>
Get the specified table from the manifest.
pub fn get_sections(&self) -> Vec<(Vec<String>, Item)>
[src]
pub fn get_sections(&self) -> Vec<(Vec<String>, Item)>
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]
pub fn write_to_file(&self, file: &mut File) -> Result<()>
Overwrite a file with TOML data.
pub fn insert_into_table(
&mut self,
table_path: &[String],
dep: &Dependency
) -> Result<()>
[src]
pub fn insert_into_table(
&mut self,
table_path: &[String],
dep: &Dependency
) -> Result<()>
Add entry to a Cargo.toml.
pub fn update_table_entry(
&mut self,
table_path: &[String],
dep: &Dependency,
dry_run: bool
) -> Result<()>
[src]
pub fn update_table_entry(
&mut self,
table_path: &[String],
dep: &Dependency,
dry_run: bool
) -> Result<()>
Update an entry in Cargo.toml.
pub fn remove_from_table(&mut self, table: &str, name: &str) -> Result<()>
[src]
pub fn remove_from_table(&mut self, table: &str, name: &str) -> Result<()>
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]
pub fn add_deps(&mut self, table: &[String], deps: &[Dependency]) -> Result<()>
Add multiple dependencies to manifest
Trait Implementations
impl Debug for Manifest
[src]
impl Debug for Manifest
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Clone for Manifest
[src]
impl Clone for Manifest
fn clone(&self) -> Manifest
[src]
fn clone(&self) -> Manifest
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl FromStr for Manifest
[src]
impl FromStr for Manifest