Struct ethers_solc::output::sources::VersionedSourceFiles
source · [−]pub struct VersionedSourceFiles(pub BTreeMap<String, Vec<VersionedSourceFile>>);Expand description
(source_file path -> SourceFile + solc version)
Tuple Fields
0: BTreeMap<String, Vec<VersionedSourceFile>>Implementations
sourceimpl VersionedSourceFiles
impl VersionedSourceFiles
pub fn is_empty(&self) -> bool
pub fn len(&self) -> usize
sourcepub fn into_ids(self) -> impl Iterator<Item = (u32, String)>
pub fn into_ids(self) -> impl Iterator<Item = (u32, String)>
Returns an iterator over the source files’ ids and path
use std::collections::BTreeMap;
use ethers_solc::sources::VersionedSourceFiles;
let sources: BTreeMap<u32,String> = files.into_ids().collect();sourcepub fn into_paths(self) -> impl Iterator<Item = (String, u32)>
pub fn into_paths(self) -> impl Iterator<Item = (String, u32)>
Returns an iterator over the source files’ paths and ids
use std::collections::BTreeMap;
use ethers_solc::artifacts::SourceFiles;
let sources :BTreeMap<String, u32> = files.into_paths().collect();sourcepub fn into_ids_with_version(
self
) -> impl Iterator<Item = (u32, String, Version)>
pub fn into_ids_with_version(
self
) -> impl Iterator<Item = (u32, String, Version)>
Returns an iterator over the source files’ ids and path
use std::collections::BTreeMap;
use semver::Version;
use ethers_solc::sources::VersionedSourceFiles;
let sources: BTreeMap<(u32, Version) ,String> = files.into_ids_with_version().map(|(id, source, version)|((id, version), source)).collect();sourcepub fn find_file(&self, source_file: impl AsRef<str>) -> Option<&SourceFile>
pub fn find_file(&self, source_file: impl AsRef<str>) -> Option<&SourceFile>
Finds the first source file with the given path
Example
use ethers_solc::Project;
use ethers_solc::artifacts::*;
let output = project.compile().unwrap().output();
let source_file = output.sources.find_file("src/Greeter.sol").unwrap();sourcepub fn find_file_and_version(
&self,
path: &str,
version: &Version
) -> Option<&SourceFile>
pub fn find_file_and_version(
&self,
path: &str,
version: &Version
) -> Option<&SourceFile>
Same as Self::find_file but also checks for version
sourcepub fn find_id(&self, id: u32) -> Option<&SourceFile>
pub fn find_id(&self, id: u32) -> Option<&SourceFile>
Finds the first source file with the given id
Example
use ethers_solc::Project;
use ethers_solc::artifacts::*;
let output = project.compile().unwrap().output();
let source_file = output.sources.find_id(0).unwrap();sourcepub fn find_id_and_version(
&self,
id: u32,
version: &Version
) -> Option<&SourceFile>
pub fn find_id_and_version(
&self,
id: u32,
version: &Version
) -> Option<&SourceFile>
Same as Self::find_id but also checks for version
sourcepub fn remove_by_path(
&mut self,
source_file: impl AsRef<str>
) -> Option<SourceFile>
pub fn remove_by_path(
&mut self,
source_file: impl AsRef<str>
) -> Option<SourceFile>
Removes the first source_file with the given path from the set
Example
use ethers_solc::Project;
use ethers_solc::artifacts::*;
let (mut sources, _) = project.compile().unwrap().output().split();
let source_file = sources.remove_by_path("src/Greeter.sol").unwrap();sourcepub fn remove_by_id(&mut self, id: u32) -> Option<SourceFile>
pub fn remove_by_id(&mut self, id: u32) -> Option<SourceFile>
Removes the first source_file with the given id from the set
Example
use ethers_solc::Project;
use ethers_solc::artifacts::*;
let (mut sources, _) = project.compile().unwrap().output().split();
let source_file = sources.remove_by_id(0).unwrap();sourcepub fn sources(&self) -> impl Iterator<Item = (&String, &SourceFile)>
pub fn sources(&self) -> impl Iterator<Item = (&String, &SourceFile)>
Iterate over all contracts and their names
sourcepub fn sources_with_version(
&self
) -> impl Iterator<Item = (&String, &SourceFile, &Version)>
pub fn sources_with_version(
&self
) -> impl Iterator<Item = (&String, &SourceFile, &Version)>
Returns an iterator over (file, SourceFile, Version)
sourcepub fn into_sources(self) -> impl Iterator<Item = (String, SourceFile)>
pub fn into_sources(self) -> impl Iterator<Item = (String, SourceFile)>
Returns an iterator over all contracts and their source names.
use std::collections::BTreeMap;
use ethers_solc::{ artifacts::* };
use ethers_solc::sources::VersionedSourceFiles;
let sources: BTreeMap<String, SourceFile> = sources
.into_sources()
.collect();sourcepub fn into_sources_with_version(
self
) -> impl Iterator<Item = (String, SourceFile, Version)>
pub fn into_sources_with_version(
self
) -> impl Iterator<Item = (String, SourceFile, Version)>
Returns an iterator over all contracts and their source names.
use std::collections::BTreeMap;
use semver::Version;
use ethers_solc::{ artifacts::* };
use ethers_solc::sources::VersionedSourceFiles;
let sources: BTreeMap<(String,Version), SourceFile> = sources
.into_sources_with_version().map(|(path, source, version)|((path,version), source))
.collect();sourcepub fn join_all(&mut self, root: impl AsRef<Path>) -> &mut Self
pub fn join_all(&mut self, root: impl AsRef<Path>) -> &mut Self
Sets the sources’ file paths to root adjoined to self.file.
sourcepub fn strip_prefix_all(&mut self, base: impl AsRef<Path>) -> &mut Self
pub fn strip_prefix_all(&mut self, base: impl AsRef<Path>) -> &mut Self
Removes base from all source file paths
Trait Implementations
sourceimpl AsMut<BTreeMap<String, Vec<VersionedSourceFile, Global>>> for VersionedSourceFiles
impl AsMut<BTreeMap<String, Vec<VersionedSourceFile, Global>>> for VersionedSourceFiles
sourceimpl AsRef<BTreeMap<String, Vec<VersionedSourceFile, Global>>> for VersionedSourceFiles
impl AsRef<BTreeMap<String, Vec<VersionedSourceFile, Global>>> for VersionedSourceFiles
sourceimpl Clone for VersionedSourceFiles
impl Clone for VersionedSourceFiles
sourcefn clone(&self) -> VersionedSourceFiles
fn clone(&self) -> VersionedSourceFiles
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 Debug for VersionedSourceFiles
impl Debug for VersionedSourceFiles
sourceimpl Default for VersionedSourceFiles
impl Default for VersionedSourceFiles
sourcefn default() -> VersionedSourceFiles
fn default() -> VersionedSourceFiles
Returns the “default value” for a type. Read more
sourceimpl<'de> Deserialize<'de> for VersionedSourceFiles
impl<'de> Deserialize<'de> for VersionedSourceFiles
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl IntoIterator for VersionedSourceFiles
impl IntoIterator for VersionedSourceFiles
sourceimpl PartialEq<VersionedSourceFiles> for VersionedSourceFiles
impl PartialEq<VersionedSourceFiles> for VersionedSourceFiles
sourcefn eq(&self, other: &VersionedSourceFiles) -> bool
fn eq(&self, other: &VersionedSourceFiles) -> bool
This method tests for self and other values to be equal, and is used
by ==. Read more
sourcefn ne(&self, other: &VersionedSourceFiles) -> bool
fn ne(&self, other: &VersionedSourceFiles) -> bool
This method tests for !=.
sourceimpl Serialize for VersionedSourceFiles
impl Serialize for VersionedSourceFiles
impl Eq for VersionedSourceFiles
impl StructuralEq for VersionedSourceFiles
impl StructuralPartialEq for VersionedSourceFiles
Auto Trait Implementations
impl RefUnwindSafe for VersionedSourceFiles
impl Send for VersionedSourceFiles
impl Sync for VersionedSourceFiles
impl Unpin for VersionedSourceFiles
impl UnwindSafe for VersionedSourceFiles
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