Struct cargo::core::Workspace
[−]
[src]
pub struct Workspace<'cfg> { /* fields omitted */ }
The core abstraction in Cargo for working with a workspace of crates.
A workspace is often created very early on and then threaded through all other functions. It's typically through this object that the current package is loaded and/or learned about.
Methods
impl<'cfg> Workspace<'cfg>
[src]
fn new(
manifest_path: &Path,
config: &'cfg Config
) -> CargoResult<Workspace<'cfg>>
manifest_path: &Path,
config: &'cfg Config
) -> CargoResult<Workspace<'cfg>>
Creates a new workspace given the target manifest pointed to by
manifest_path
.
This function will construct the entire workspace by determining the
root and all member packages. It will then validate the workspace
before returning it, so Ok
is only returned for valid workspaces.
fn ephemeral(
package: Package,
config: &'cfg Config,
target_dir: Option<Filesystem>,
require_optional_deps: bool
) -> CargoResult<Workspace<'cfg>>
package: Package,
config: &'cfg Config,
target_dir: Option<Filesystem>,
require_optional_deps: bool
) -> CargoResult<Workspace<'cfg>>
Creates a "temporary workspace" from one package which only contains that package.
This constructor will not touch the filesystem and only creates an in-memory workspace. That is, all configuration is ignored, it's just intended for that one package.
This is currently only used in niche situations like cargo install
or
cargo package
.
fn current(&self) -> CargoResult<&Package>
Returns the current package of this workspace.
Note that this can return an error if it the current manifest is actually a "virtual Cargo.toml", in which case an error is returned indicating that something else should be passed.
fn current_opt(&self) -> Option<&Package>
fn config(&self) -> &'cfg Config
Returns the Config
this workspace is associated with.
fn profiles(&self) -> &Profiles
fn root(&self) -> &Path
Returns the root path of this workspace.
That is, this returns the path of the directory containing the
Cargo.toml
which is the root of this workspace.
fn target_dir(&self) -> Filesystem
fn root_replace(&self) -> &[(PackageIdSpec, Dependency)]
Returns the root [replace] section of this workspace.
This may be from a virtual crate or an actual crate.
fn members<'a>(&'a self) -> Members<'a, 'cfg>
Returns an iterator over all packages in this workspace