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§

Converts all \\ separators in all paths to /

Convenience function fo Self::slash_paths()

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();

This returns a chained iterator of both cached and recompiled contract artifacts that yields the contract name and the corresponding artifact

Example
use std::collections::btree_map::BTreeMap;
use ethers_solc::ConfigurableContractArtifact;
use ethers_solc::Project;

let project = Project::builder().build().unwrap();
let artifacts: BTreeMap<String, &ConfigurableContractArtifact> = project.compile().unwrap().artifacts().collect();

This returns a chained iterator of both cached and recompiled contract artifacts that yields the contract name and the corresponding artifact

Example
use std::collections::btree_map::BTreeMap;
use semver::Version;
use ethers_solc::ConfigurableContractArtifact;
use ethers_solc::Project;

let project = Project::builder().build().unwrap();
let artifacts: BTreeMap<String, (&ConfigurableContractArtifact, &Version)> = project.compile().unwrap().versioned_artifacts().collect();

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()

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

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());

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();

Whether this type has a compiler output

Whether this type does not contain compiled contracts

Whether there were errors

Whether there were warnings

Returns the set of Artifacts that were cached and got reused during crate::Project::compile()

Returns the set of Artifacts that were compiled with solc in crate::Project::compile()

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

Removes the contract with matching path and name using the <path>:<contractname> pattern where path is optional.

If the path segment is None, then the first matching Contract is returned, see Self::remove_first

Example
use ethers_solc::Project;
use ethers_solc::artifacts::*;
use ethers_solc::info::ContractInfo;

let  output = project.compile().unwrap();
let info = ContractInfo::new("src/Greeter.sol:Greeter");
let contract = output.find_contract(&info).unwrap();

Finds the artifact with matching path and name

Example
use ethers_solc::Project;
use ethers_solc::artifacts::*;
let output = project.compile().unwrap();
let contract = output.find("src/Greeter.sol", "Greeter").unwrap();

Finds the first contract with the given name

Finds the artifact with matching path and name

Example
use ethers_solc::Project;
use ethers_solc::artifacts::*;
let output = project.compile().unwrap();
let contract = output.find("src/Greeter.sol", "Greeter").unwrap();

Removes the first contract with the given name from the set

Example
use ethers_solc::Project;
use ethers_solc::artifacts::*;
let mut output = project.compile().unwrap();
let contract = output.remove_first("Greeter").unwrap();

Removes the contract with matching path and name using the <path>:<contractname> pattern where path is optional.

If the path segment is None, then the first matching Contract is returned, see Self::remove_first

Example
use ethers_solc::Project;
use ethers_solc::artifacts::*;
use ethers_solc::info::ContractInfo;
let mut output = project.compile().unwrap();
let info = ContractInfo::new("src/Greeter.sol:Greeter");
let contract = output.remove_contract(&info).unwrap();

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};
use ethers_solc::contracts::ArtifactContracts;

let project = Project::builder().build().unwrap();
let contracts: ArtifactContracts = project.compile().unwrap().into_contract_bytecodes().collect();

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more