Struct foundry_compilers::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.
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.
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.
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.
§Examples
use foundry_compilers::{artifacts::*, Project};
let project = Project::builder().build()?;
let output = project.compile()?.into_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
§Examples
use foundry_compilers::{artifacts::*, Project};
let project = Project::builder().build()?;
let output = project.compile()?.into_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
§Examples
use foundry_compilers::{artifacts::*, Project};
let project = Project::builder().build()?;
let (mut sources, _) = project.compile()?.into_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
§Examples
use foundry_compilers::{artifacts::*, Project};
let project = Project::builder().build()?;
let (mut sources, _) = project.compile()?.into_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)>
Returns an iterator 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.
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.
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 Freeze for VersionedSourceFiles
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<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more