Struct ethers_solc::resolver::Graph
source · pub struct Graph { /* private fields */ }
Expand description
Represents a fully-resolved solidity dependency graph. Each node in the graph is a file and edges represent dependencies between them. See also https://docs.soliditylang.org/en/latest/layout-of-source-files.html?highlight=import#importing-other-source-files
Implementations§
source§impl Graph
impl Graph
sourcepub fn print_with_options(&self, opts: TreeOptions)
pub fn print_with_options(&self, opts: TreeOptions)
Print the graph to StdOut
using the provided TreeOptions
sourcepub fn imported_nodes(&self, from: usize) -> &[usize]
pub fn imported_nodes(&self, from: usize) -> &[usize]
Returns a list of nodes the given node index points to for the given kind.
sourcepub fn all_imported_nodes(
&self,
from: usize
) -> impl Iterator<Item = usize> + '_
pub fn all_imported_nodes( &self, from: usize ) -> impl Iterator<Item = usize> + '_
Returns an iterator that yields all imports of a node and all their imports
sourcepub fn files(&self) -> &HashMap<PathBuf, usize>
pub fn files(&self) -> &HashMap<PathBuf, usize>
Returns all the resolved files and their index in the graph
sourcepub fn node_ids(&self, start: usize) -> impl Iterator<Item = usize> + '_
pub fn node_ids(&self, start: usize) -> impl Iterator<Item = usize> + '_
Returns an iterator that yields all nodes of the dependency tree that the given node id spans, starting with the node itself.
§Panics
if the start
node id is not included in the graph
sourcepub fn nodes(&self, start: usize) -> impl Iterator<Item = &Node> + '_
pub fn nodes(&self, start: usize) -> impl Iterator<Item = &Node> + '_
Same as Self::node_ids
but returns the actual Node
sourcepub fn into_sources(self) -> (Sources, GraphEdges)
pub fn into_sources(self) -> (Sources, GraphEdges)
Consumes the Graph
, effectively splitting the nodes
and the GraphEdges
off and
returning the nodes
converted to Sources
sourcepub fn input_nodes(&self) -> impl Iterator<Item = &Node>
pub fn input_nodes(&self) -> impl Iterator<Item = &Node>
Returns an iterator that yields only those nodes that represent input files.
See Self::resolve_sources
This won’t yield any resolved library nodes
sourcepub fn imports(&self, path: impl AsRef<Path>) -> HashSet<&PathBuf>
pub fn imports(&self, path: impl AsRef<Path>) -> HashSet<&PathBuf>
Returns all files imported by the given file
sourcepub fn resolve_sources(
paths: &ProjectPathsConfig,
sources: Sources
) -> Result<Graph>
pub fn resolve_sources( paths: &ProjectPathsConfig, sources: Sources ) -> Result<Graph>
Resolves a number of sources within the given config
sourcepub fn resolve(paths: &ProjectPathsConfig) -> Result<Graph>
pub fn resolve(paths: &ProjectPathsConfig) -> Result<Graph>
Resolves the dependencies of a project’s source contracts
source§impl Graph
impl Graph
sourcepub fn into_sources_by_version(
self,
offline: bool
) -> Result<(VersionedSources, GraphEdges)>
Available on crate feature svm-solc
and non-WebAssembly only.
pub fn into_sources_by_version( self, offline: bool ) -> Result<(VersionedSources, GraphEdges)>
svm-solc
and non-WebAssembly only.Consumes the nodes of the graph and returns all input files together with their appropriate version and the edges of the graph
First we determine the compatible version for each input file (from sources and test folder,
see Self::resolve
) and then we add all resolved library imports.
sourcepub fn ensure_compatible_imports(&self, offline: bool) -> Result<()>
Available on crate feature svm-solc
and non-WebAssembly only.
pub fn ensure_compatible_imports(&self, offline: bool) -> Result<()>
svm-solc
and non-WebAssembly only.Ensures that all files are compatible with all of their imports.