use crate::contracts::VersionedContract;
use std::{
collections::HashMap,
hash::Hash,
ops::{Deref, DerefMut},
path::{Path, PathBuf},
};
pub struct MappedArtifactFiles<'a> {
pub files: HashMap<MappedArtifactFile, Vec<MappedContract<'a>>>,
}
impl<'a> MappedArtifactFiles<'a> {
pub fn with_capacity(len: usize) -> Self {
Self { files: HashMap::with_capacity(len) }
}
}
impl<'a> Deref for MappedArtifactFiles<'a> {
type Target = HashMap<MappedArtifactFile, Vec<MappedContract<'a>>>;
fn deref(&self) -> &Self::Target {
&self.files
}
}
impl<'a> DerefMut for MappedArtifactFiles<'a> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.files
}
}
#[derive(Debug, Hash, PartialEq, Eq)]
pub struct MappedArtifactFile {
lower_case_path: String,
}
impl MappedArtifactFile {
pub fn new(path: &Path) -> Self {
Self { lower_case_path: path.to_string_lossy().to_lowercase() }
}
}
pub struct MappedContract<'a> {
pub file: &'a str,
pub name: &'a str,
pub contract: &'a VersionedContract,
pub artifact_path: PathBuf,
}