Struct contract_build::Workspace
source · pub struct Workspace { /* private fields */ }Expand description
Make a copy of a cargo workspace, maintaining only the directory structure and manifest files. Relative paths to source files and non-workspace dependencies are rewritten to absolute paths to the original locations.
This allows custom amendments to be made to the manifest files without editing the originals directly.
Implementations§
source§impl Workspace
impl Workspace
sourcepub fn new(metadata: &CargoMetadata, root_package: &PackageId) -> Result<Self>
pub fn new(metadata: &CargoMetadata, root_package: &PackageId) -> Result<Self>
Create a new Workspace from the supplied cargo metadata.
sourcepub fn with_root_package_manifest<F>(&mut self, f: F) -> Result<&mut Self>where
F: FnOnce(&mut Manifest) -> Result<()>,
pub fn with_root_package_manifest<F>(&mut self, f: F) -> Result<&mut Self>where F: FnOnce(&mut Manifest) -> Result<()>,
Amend the root package manifest using the supplied function.
Note
The root package is the current workspace package being built, not to be confused with
the workspace root (where the top level workspace Cargo.toml is defined).
sourcepub fn with_contract_manifest<F>(
&mut self,
package_path: &Path,
f: F
) -> Result<&mut Self>where
F: FnOnce(&mut Manifest) -> Result<()>,
pub fn with_contract_manifest<F>( &mut self, package_path: &Path, f: F ) -> Result<&mut Self>where F: FnOnce(&mut Manifest) -> Result<()>,
Amend the manifest of the package at package_path using the supplied function.
sourcepub fn write<P: AsRef<Path>>(
&mut self,
target: P
) -> Result<Vec<(PackageId, ManifestPath)>>
pub fn write<P: AsRef<Path>>( &mut self, target: P ) -> Result<Vec<(PackageId, ManifestPath)>>
Writes the amended manifests to the target directory, retaining the workspace directory
structure, but only with the Cargo.toml files.
Relative paths will be rewritten to absolute paths from the original workspace root, except intra-workspace relative dependency paths which will be preserved.
Returns the paths of the new manifests.
sourcepub fn using_temp<F>(&mut self, f: F) -> Result<()>where
F: FnOnce(&ManifestPath) -> Result<()>,
pub fn using_temp<F>(&mut self, f: F) -> Result<()>where F: FnOnce(&ManifestPath) -> Result<()>,
Copy the workspace with amended manifest files to a temporary directory, executing the supplied function with the root manifest path before the directory is cleaned up.