Struct ethers_solc::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§
source§impl VersionedSourceFiles
impl VersionedSourceFiles
sourcepub fn slash_paths(&mut self)
pub fn slash_paths(&mut self)
Converts all \\
separators in all paths to /
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§
source§impl AsMut<BTreeMap<String, Vec<VersionedSourceFile>>> for VersionedSourceFiles
impl AsMut<BTreeMap<String, Vec<VersionedSourceFile>>> for VersionedSourceFiles
source§impl AsRef<BTreeMap<String, Vec<VersionedSourceFile>>> for VersionedSourceFiles
impl AsRef<BTreeMap<String, Vec<VersionedSourceFile>>> for VersionedSourceFiles
source§impl Clone for VersionedSourceFiles
impl Clone for VersionedSourceFiles
source§fn clone(&self) -> VersionedSourceFiles
fn clone(&self) -> VersionedSourceFiles
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for VersionedSourceFiles
impl Debug for VersionedSourceFiles
source§impl Default for VersionedSourceFiles
impl Default for VersionedSourceFiles
source§fn default() -> VersionedSourceFiles
fn default() -> VersionedSourceFiles
source§impl<'de> Deserialize<'de> for VersionedSourceFiles
impl<'de> Deserialize<'de> for VersionedSourceFiles
source§fn 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>,
source§impl IntoIterator for VersionedSourceFiles
impl IntoIterator for VersionedSourceFiles
source§impl PartialEq for VersionedSourceFiles
impl PartialEq for VersionedSourceFiles
source§fn eq(&self, other: &VersionedSourceFiles) -> bool
fn eq(&self, other: &VersionedSourceFiles) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl Serialize for VersionedSourceFiles
impl Serialize for VersionedSourceFiles
impl Eq 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§
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.