Skip to main content

add

Function add 

Source
pub fn add(cfg: &Config, spec: AddSpec) -> Result<AddReport, PkgError>
Expand description

Insert (or replace) a [deps.<name>] entry in the manifest.

Performs no network I/O and never invokes the fetcher; callers run install afterwards. If the manifest file does not exist yet a minimal [package] block is synthesised, using the manifest directory’s name as the package name.

The manifest is rewritten through toml::to_string, so comments and formatting of an existing file are not preserved (this matches the CLI’s historical behaviour; update is the format-preserving path).

§Errors