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>
pub fn with_root_package_manifest<F>(&mut self, f: F) -> Result<&mut Self>
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<()>
pub fn using_temp<F>(&mut self, f: F) -> 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.
Auto Trait Implementations§
impl Freeze for Workspace
impl RefUnwindSafe for Workspace
impl Send for Workspace
impl Sync for Workspace
impl Unpin for Workspace
impl UnwindSafe for Workspace
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more