diff --git a/crates/rattler_conda_types/src/conda_lock/mod.rs b/crates/rattler_conda_types/src/conda_lock/mod.rs index 794f9e3aa..c55199a25 100644 --- a/crates/rattler_conda_types/src/conda_lock/mod.rs +++ b/crates/rattler_conda_types/src/conda_lock/mod.rs @@ -84,6 +84,13 @@ impl CondaLock { pub fn from_path(path: &Path) -> Result { Self::from_reader(File::open(path)?) } + + /// Writes the conda lock to a file + pub fn to_path(&self, path: &Path) -> Result<(), std::io::Error> { + let file = std::fs::File::create(path)?; + serde_yaml::to_writer(file, self) + .map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err)) + } } #[derive(Serialize, Deserialize)] diff --git a/crates/rattler_conda_types/src/repo_data/mod.rs b/crates/rattler_conda_types/src/repo_data/mod.rs index beb972f45..cdc842e00 100644 --- a/crates/rattler_conda_types/src/repo_data/mod.rs +++ b/crates/rattler_conda_types/src/repo_data/mod.rs @@ -61,7 +61,7 @@ pub struct ChannelInfo { #[serde_as] #[skip_serializing_none] #[sorted] -#[derive(Debug, Deserialize, Serialize, Eq, PartialEq, Ord, PartialOrd, Clone)] +#[derive(Debug, Deserialize, Serialize, Eq, PartialEq, Ord, PartialOrd, Clone, Hash)] pub struct PackageRecord { /// Optionally the architecture the package supports pub arch: Option, diff --git a/crates/rattler_conda_types/src/repo_data_record.rs b/crates/rattler_conda_types/src/repo_data_record.rs index 5715473d6..b05e06f61 100644 --- a/crates/rattler_conda_types/src/repo_data_record.rs +++ b/crates/rattler_conda_types/src/repo_data_record.rs @@ -6,7 +6,7 @@ use url::Url; /// Information about a package from repodata. It includes a [`crate::PackageRecord`] but it also stores /// the source of the data (like the url and the channel). -#[derive(Debug, Deserialize, Serialize, Eq, PartialEq, Ord, PartialOrd, Clone)] +#[derive(Debug, Deserialize, Serialize, Eq, PartialEq, Ord, PartialOrd, Clone, Hash)] pub struct RepoDataRecord { /// The data stored in the repodata.json. #[serde(flatten)] diff --git a/crates/rattler_repodata_gateway/src/sparse/mod.rs b/crates/rattler_repodata_gateway/src/sparse/mod.rs index 71799ee73..37d38adf1 100644 --- a/crates/rattler_repodata_gateway/src/sparse/mod.rs +++ b/crates/rattler_repodata_gateway/src/sparse/mod.rs @@ -103,10 +103,12 @@ impl SparseRepoData { /// /// This will parse the records for the specified packages as well as all the packages these records /// depend on. - pub fn load_records_recursive( - repo_data: &[SparseRepoData], + pub fn load_records_recursive<'a>( + repo_data: impl IntoIterator, package_names: impl IntoIterator>, ) -> io::Result>> { + let repo_data: Vec<_> = repo_data.into_iter().collect(); + // Construct the result map let mut result = Vec::from_iter((0..repo_data.len()).map(|_| Vec::new())); @@ -155,6 +157,11 @@ impl SparseRepoData { Ok(result) } + + /// Returns the subdirectory from which this repodata was loaded + pub fn subdir(&self) -> &str { + &self.subdir + } } /// A serde compatible struct that only sparsely parses a repodata.json file.