Struct ethers_solc::ProjectCompileOutput
source · [−]pub struct ProjectCompileOutput<T: ArtifactOutput = ConfigurableArtifacts> { /* private fields */ }Expand description
Contains a mixture of already compiled/cached artifacts and the input set of sources that still need to be compiled.
Implementations
sourceimpl<T: ArtifactOutput> ProjectCompileOutput<T>
impl<T: ArtifactOutput> ProjectCompileOutput<T>
sourcepub fn into_artifacts(self) -> impl Iterator<Item = (ArtifactId, T::Artifact)>
pub fn into_artifacts(self) -> impl Iterator<Item = (ArtifactId, T::Artifact)>
All artifacts together with their contract file name and name <file name>:<name>
This returns a chained iterator of both cached and recompiled contract artifacts
Example
use std::collections::btree_map::BTreeMap;
use ethers_solc::ConfigurableContractArtifact;
use ethers_solc::{ArtifactId, Project};
let project = Project::builder().build().unwrap();
let contracts: BTreeMap<ArtifactId, ConfigurableContractArtifact> = project.compile().unwrap().into_artifacts().collect();sourcepub fn into_artifacts_with_files(
self
) -> impl Iterator<Item = (String, String, T::Artifact)>
pub fn into_artifacts_with_files(
self
) -> impl Iterator<Item = (String, String, T::Artifact)>
All artifacts together with their contract file and name as tuple (file, contract name, artifact)
This returns a chained iterator of both cached and recompiled contract artifacts
Example
use std::collections::btree_map::BTreeMap;
use ethers_solc::{ConfigurableContractArtifact, Project};
let project = Project::builder().build().unwrap();
let contracts: Vec<(String, String, ConfigurableContractArtifact)> = project.compile().unwrap().into_artifacts_with_files().collect();NOTE the file will be returned as is, see also Self::with_stripped_file_prefixes()
sourcepub fn into_artifacts_with_sources(
self
) -> (BTreeMap<ArtifactId, T::Artifact>, VersionedSourceFiles)
pub fn into_artifacts_with_sources(
self
) -> (BTreeMap<ArtifactId, T::Artifact>, VersionedSourceFiles)
All artifacts together with their ID and the sources of the project.
Note: this only returns the SourceFiles for freshly compiled contracts because, if not
included in the Artifact itself (see
crate::ConfigurableContractArtifact::source_file()), is only available via the solc
CompilerOutput
sourcepub fn with_stripped_file_prefixes(self, base: impl AsRef<Path>) -> Self
pub fn with_stripped_file_prefixes(self, base: impl AsRef<Path>) -> Self
Strips the given prefix from all artifact file paths to make them relative to the given
base argument
Example
Make all artifact files relative to the project’s root directory
use ethers_solc::Project;
let project = Project::builder().build().unwrap();
let output = project.compile().unwrap().with_stripped_file_prefixes(project.root());sourcepub fn output(self) -> AggregatedCompilerOutput
pub fn output(self) -> AggregatedCompilerOutput
Get the (merged) solc compiler output
use std::collections::btree_map::BTreeMap;
use ethers_solc::artifacts::contract::Contract;
use ethers_solc::Project;
let project = Project::builder().build().unwrap();
let contracts: BTreeMap<String, Contract> =
project.compile().unwrap().output().contracts_into_iter().collect();sourcepub fn has_compiled_contracts(&self) -> bool
pub fn has_compiled_contracts(&self) -> bool
Whether this type has a compiler output
sourcepub fn is_unchanged(&self) -> bool
pub fn is_unchanged(&self) -> bool
Whether this type does not contain compiled contracts
sourcepub fn has_compiler_errors(&self) -> bool
pub fn has_compiler_errors(&self) -> bool
Whether there were errors
sourcepub fn has_compiler_warnings(&self) -> bool
pub fn has_compiler_warnings(&self) -> bool
Whether there were warnings
sourcepub fn remove(&mut self, contract_name: impl AsRef<str>) -> Option<T::Artifact>
pub fn remove(&mut self, contract_name: impl AsRef<str>) -> Option<T::Artifact>
Finds the first contract with the given name and removes it from the set
sourcepub fn cached_artifacts(&self) -> &Artifacts<T::Artifact>
pub fn cached_artifacts(&self) -> &Artifacts<T::Artifact>
Returns the set of Artifacts that were cached and got reused during
crate::Project::compile()
sourcepub fn compiled_artifacts(&self) -> &Artifacts<T::Artifact>
pub fn compiled_artifacts(&self) -> &Artifacts<T::Artifact>
Returns the set of Artifacts that were compiled with solc in
crate::Project::compile()
sourcepub fn compiled_contracts_by_compiler_version(
&self
) -> BTreeMap<Version, Vec<(String, Contract)>>
pub fn compiled_contracts_by_compiler_version(
&self
) -> BTreeMap<Version, Vec<(String, Contract)>>
Returns a BTreeMap that maps the compiler version used during
crate::Project::compile() to a Vector of tuples containing the contract name and the
Contract
sourceimpl<T: ArtifactOutput> ProjectCompileOutput<T> where
T::Artifact: Clone,
impl<T: ArtifactOutput> ProjectCompileOutput<T> where
T::Artifact: Clone,
sourceimpl ProjectCompileOutput<ConfigurableArtifacts>
impl ProjectCompileOutput<ConfigurableArtifacts>
sourcepub fn into_contract_bytecodes(
self
) -> impl Iterator<Item = (ArtifactId, CompactContractBytecode)>
pub fn into_contract_bytecodes(
self
) -> impl Iterator<Item = (ArtifactId, CompactContractBytecode)>
A helper functions that extracts the underlying CompactContractBytecode from the
crate::ConfigurableContractArtifact
Example
use std::collections::btree_map::BTreeMap;
use ethers_solc::artifacts::contract::CompactContractBytecode;
use ethers_solc::{ArtifactId, Project};
let project = Project::builder().build().unwrap();
let contracts: BTreeMap<ArtifactId, CompactContractBytecode> = project.compile().unwrap().into_contract_bytecodes().collect();Trait Implementations
sourceimpl<T: Clone + ArtifactOutput> Clone for ProjectCompileOutput<T> where
T::Artifact: Clone,
T::Artifact: Clone,
impl<T: Clone + ArtifactOutput> Clone for ProjectCompileOutput<T> where
T::Artifact: Clone,
T::Artifact: Clone,
sourcefn clone(&self) -> ProjectCompileOutput<T>
fn clone(&self) -> ProjectCompileOutput<T>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl<T: Debug + ArtifactOutput> Debug for ProjectCompileOutput<T> where
T::Artifact: Debug,
T::Artifact: Debug,
impl<T: Debug + ArtifactOutput> Debug for ProjectCompileOutput<T> where
T::Artifact: Debug,
T::Artifact: Debug,
sourceimpl<T: Default + ArtifactOutput> Default for ProjectCompileOutput<T> where
T::Artifact: Default,
T::Artifact: Default,
impl<T: Default + ArtifactOutput> Default for ProjectCompileOutput<T> where
T::Artifact: Default,
T::Artifact: Default,
sourcefn default() -> ProjectCompileOutput<T>
fn default() -> ProjectCompileOutput<T>
Returns the “default value” for a type. Read more
sourceimpl<T: ArtifactOutput> Display for ProjectCompileOutput<T>
impl<T: ArtifactOutput> Display for ProjectCompileOutput<T>
sourceimpl<T: PartialEq + ArtifactOutput> PartialEq<ProjectCompileOutput<T>> for ProjectCompileOutput<T> where
T::Artifact: PartialEq,
T::Artifact: PartialEq,
impl<T: PartialEq + ArtifactOutput> PartialEq<ProjectCompileOutput<T>> for ProjectCompileOutput<T> where
T::Artifact: PartialEq,
T::Artifact: PartialEq,
sourcefn eq(&self, other: &ProjectCompileOutput<T>) -> bool
fn eq(&self, other: &ProjectCompileOutput<T>) -> bool
This method tests for self and other values to be equal, and is used
by ==. Read more
sourcefn ne(&self, other: &ProjectCompileOutput<T>) -> bool
fn ne(&self, other: &ProjectCompileOutput<T>) -> bool
This method tests for !=.
impl<T: ArtifactOutput> StructuralPartialEq for ProjectCompileOutput<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for ProjectCompileOutput<T> where
<T as ArtifactOutput>::Artifact: RefUnwindSafe,
impl<T> Send for ProjectCompileOutput<T> where
<T as ArtifactOutput>::Artifact: Send,
impl<T> Sync for ProjectCompileOutput<T> where
<T as ArtifactOutput>::Artifact: Sync,
impl<T> Unpin for ProjectCompileOutput<T>
impl<T> UnwindSafe for ProjectCompileOutput<T> where
<T as ArtifactOutput>::Artifact: RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more