[][src]Struct cargo::core::Workspace

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]

pub fn new(
    manifest_path: &Path,
    config: &'cfg Config
) -> CargoResult<Workspace<'cfg>>
[src]

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.

pub fn ephemeral(
    package: Package,
    config: &'cfg Config,
    target_dir: Option<Filesystem>,
    require_optional_deps: bool
) -> CargoResult<Workspace<'cfg>>
[src]

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.

pub fn current(&self) -> CargoResult<&Package>
[src]

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.

pub fn current_opt(&self) -> Option<&Package>
[src]

pub fn is_virtual(&self) -> bool
[src]

pub fn config(&self) -> &'cfg Config
[src]

Returns the Config this workspace is associated with.

pub fn profiles(&self) -> &Profiles
[src]

pub fn root(&self) -> &Path
[src]

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.

pub fn target_dir(&self) -> Filesystem
[src]

pub fn root_replace(&self) -> &[(PackageIdSpec, Dependency)]
[src]

Returns the root [replace] section of this workspace.

This may be from a virtual crate or an actual crate.

pub fn root_patch(&self) -> &HashMap<Url, Vec<Dependency>>
[src]

Returns the root [patch] section of this workspace.

This may be from a virtual crate or an actual crate.

Important traits for Members<'a, 'cfg>
pub fn members<'a>(&'a self) -> Members<'a, 'cfg>
[src]

Returns an iterator over all packages in this workspace

Important traits for Members<'a, 'cfg>
pub fn default_members<'a>(&'a self) -> Members<'a, 'cfg>
[src]

Returns an iterator over default packages in this workspace

pub fn is_member(&self, pkg: &Package) -> bool
[src]

Returns true if the package is a member of the workspace.

pub fn is_ephemeral(&self) -> bool
[src]

pub fn require_optional_deps(&self) -> bool
[src]

pub fn set_require_optional_deps<'a>(
    &'a mut self,
    require_optional_deps: bool
) -> &mut Workspace<'cfg>
[src]

pub fn load(&self, manifest_path: &Path) -> CargoResult<Package>
[src]

pub fn preload(&self, registry: &mut PackageRegistry<'cfg>)
[src]

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.

pub fn emit_warnings(&self) -> CargoResult<()>
[src]

Trait Implementations

impl<'cfg> Debug for Workspace<'cfg>
[src]

Auto Trait Implementations

impl<'cfg> !Send for Workspace<'cfg>

impl<'cfg> !Sync for Workspace<'cfg>

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Erased for T

impl<T> Same for T

type Output = T

Should always be Self