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.
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.
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
.
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.
Returns the Config
this workspace is associated with.
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.
Returns the root [replace] section of this workspace.
This may be from a virtual crate or an actual crate.
Returns the root [patch] section of this workspace.
This may be from a virtual crate or an actual crate.
Returns an iterator over all packages in this workspace
Returns an iterator over default packages in this workspace
Returns true if the package is a member of the workspace.
Preload the provided registry with already loaded packages.
A workspace may load packages during construction/parsing/early phases
for various operations, and this preload step avoids doubly-loading and
parsing crates on the filesystem by inserting them all into the registry
with their in-memory formats.
Formats the value using the given formatter. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static