Struct ethcontract_common::artifact::Artifact
source · pub struct Artifact { /* private fields */ }Expand description
An entity that contains compiled contracts.
Implementations§
source§impl Artifact
impl Artifact
sourcepub fn with_origin(origin: impl Into<String>) -> Self
pub fn with_origin(origin: impl Into<String>) -> Self
Creates a new artifact with an origin information.
sourcepub fn origin(&self) -> &str
pub fn origin(&self) -> &str
Provides description of where this artifact comes from.
This function is used when a human-readable reference to the artifact is required. It could be anything: path to a json file, url, etc.
sourcepub fn set_origin(&mut self, origin: impl Into<String>)
pub fn set_origin(&mut self, origin: impl Into<String>)
Sets new origin for the artifact.
Artifact loaders will set origin to something meaningful in most cases, so this function should not be used often. There are cases when it is required, though.
sourcepub fn contains(&self, name: &str) -> bool
pub fn contains(&self, name: &str) -> bool
Returns true if this artifact has a contract with the given name.
sourcepub fn get(&self, name: &str) -> Option<&Contract>
pub fn get(&self, name: &str) -> Option<&Contract>
Looks up contract by its name and returns a reference to it.
Some artifact formats allow exporting a single unnamed contract. In this case, the contract will have an empty string as its name.
sourcepub fn get_mut(&mut self, name: &str) -> Option<ContractMut<'_>>
pub fn get_mut(&mut self, name: &str) -> Option<ContractMut<'_>>
Looks up contract by its name and returns a handle that allows safely mutating it.
The returned handle does not allow renaming contract. For that, you’ll need to remove it and add again.
sourcepub fn insert(&mut self, contract: Contract) -> InsertResult<'_>
pub fn insert(&mut self, contract: Contract) -> InsertResult<'_>
Inserts a new contract to the artifact.
If contract with this name already exists, replaces it and returns the old contract.
sourcepub fn remove(&mut self, name: &str) -> Option<Contract>
pub fn remove(&mut self, name: &str) -> Option<Contract>
Removes contract from the artifact.
Returns removed contract or None if contract with the given name
wasn’t found.