Struct contract_build::Workspace
source · pub struct Workspace { /* private fields */ }
Expand description
Make a copy of a contract project manifest, allow modifications to be made to it, rewrite the paths to point to the original project files, then write to a temporary directory.
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 and the id of the root contract package.
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 write<P: AsRef<Path>>(&mut self, target: P) -> Result<ManifestPath>
pub fn write<P: AsRef<Path>>(&mut self, target: P) -> Result<ManifestPath>
Writes the amended manifest to the target
directory. Relative paths will be
rewritten to absolute paths from the original project root.
Returns the path of the new manifest.
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<()>,
Write the amended manifest file to a temporary directory, then execute the supplied function with the temporary manifest path before the directory is cleaned up.