Struct cargo_edit::LocalManifest
source · [−]Expand description
A Cargo manifest that is available locally.
Fields
path: PathBufPath to the manifest
manifest: ManifestManifest contents
Implementations
sourceimpl LocalManifest
impl LocalManifest
sourcepub fn find(path: Option<&Path>) -> CargoResult<Self>
pub fn find(path: Option<&Path>) -> CargoResult<Self>
Construct a LocalManifest. If no path is provided, make an educated guess as to which one
the user means.
sourcepub fn try_new(path: &Path) -> CargoResult<Self>
pub fn try_new(path: &Path) -> CargoResult<Self>
Construct the LocalManifest corresponding to the Path provided.
sourcepub fn write(&self) -> CargoResult<()>
pub fn write(&self) -> CargoResult<()>
Write changes back to the file
sourcepub fn remove_from_table(
&mut self,
table_path: &[String],
name: &str
) -> CargoResult<()>
pub fn remove_from_table(
&mut self,
table_path: &[String],
name: &str
) -> CargoResult<()>
Remove entry from a Cargo.toml.
Examples
use cargo_edit::{Dependency, LocalManifest, Manifest, RegistrySource};
use toml_edit;
let root = std::path::PathBuf::from("/").canonicalize().unwrap();
let path = root.join("Cargo.toml");
let manifest: toml_edit::Document = "
[dependencies]
cargo-edit = '0.1.0'
".parse().unwrap();
let mut manifest = LocalManifest { path, manifest: Manifest { data: manifest } };
assert!(manifest.remove_from_table(&["dependencies".to_owned()], "cargo-edit").is_ok());
assert!(manifest.remove_from_table(&["dependencies".to_owned()], "cargo-edit").is_err());
assert!(!manifest.data.contains_key("dependencies"));sourcepub fn get_dependency_tables_mut<'r>(
&'r mut self
) -> impl Iterator<Item = &'_ mut dyn TableLike> + 'r
pub fn get_dependency_tables_mut<'r>(
&'r mut self
) -> impl Iterator<Item = &'_ mut dyn TableLike> + 'r
Allow mutating depedencies, wherever they live
sourcepub fn set_package_version(&mut self, version: &Version)
pub fn set_package_version(&mut self, version: &Version)
Override the manifest’s version
Trait Implementations
sourceimpl Debug for LocalManifest
impl Debug for LocalManifest
sourceimpl Deref for LocalManifest
impl Deref for LocalManifest
Auto Trait Implementations
impl RefUnwindSafe for LocalManifest
impl Send for LocalManifest
impl Sync for LocalManifest
impl Unpin for LocalManifest
impl UnwindSafe for LocalManifest
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more