-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PubGrub resolver initial implementation
commit-id:d55b5ecb
- Loading branch information
Showing
18 changed files
with
1,045 additions
and
69 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use crate::core::{Package, PackageId, Summary}; | ||
use crate::resolver::algorithm::provider::PubGrubPackage; | ||
use once_map::OnceMap; | ||
use std::sync::Arc; | ||
|
||
/// In-memory index of package metadata. | ||
#[derive(Default, Clone)] | ||
pub struct InMemoryIndex(Arc<SharedInMemoryIndex>); | ||
|
||
#[derive(Default)] | ||
struct SharedInMemoryIndex { | ||
/// A map from package name to the metadata for that package and the index where the metadata | ||
/// came from. | ||
packages: FxOnceMap<PubGrubPackage, Arc<VersionsResponse>>, | ||
|
||
/// A map from package ID to metadata for that distribution. | ||
distributions: FxOnceMap<PackageId, Arc<MetadataResponse>>, | ||
} | ||
|
||
pub(crate) type FxOnceMap<K, V> = OnceMap<K, V>; | ||
|
||
impl InMemoryIndex { | ||
/// Returns a reference to the package metadata map. | ||
pub fn packages(&self) -> &FxOnceMap<PubGrubPackage, Arc<VersionsResponse>> { | ||
&self.0.packages | ||
} | ||
|
||
/// Returns a reference to the distribution metadata map. | ||
pub fn distributions(&self) -> &FxOnceMap<PackageId, Arc<MetadataResponse>> { | ||
&self.0.distributions | ||
} | ||
} | ||
|
||
// pub struct VersionsResponse; | ||
#[derive(Debug)] | ||
pub enum VersionsResponse { | ||
Found(Vec<Summary>), | ||
} | ||
|
||
// pub struct MetadataResponse; | ||
pub enum MetadataResponse { | ||
Found(Package), | ||
} |
Oops, something went wrong.