pub trait QueryVersion<Ref, Id, C, T>: QueryStore<Ref, T>where
C: FromIterator<(AtomTag, Version, Id)> + IntoIterator<Item = (AtomTag, Version, Id)>,
Ref: UnpackRef<Id> + Debug,
Self: Debug,
T: Send,{
// Provided methods
fn process_atoms(
refs: impl IntoIterator<Item = Ref>,
) -> <C as IntoIterator>::IntoIter { ... }
fn get_atoms(
&self,
transport: Option<&mut T>,
) -> Result<<C as IntoIterator>::IntoIter, <Self as QueryStore<Ref, T>>::Error> { ... }
fn process_highest_match(
atoms: <C as IntoIterator>::IntoIter,
tag: &AtomTag,
req: &VersionReq,
) -> Option<(Version, Id)> { ... }
fn process_root(atoms: <C as IntoIterator>::IntoIter) -> Option<Id> { ... }
fn get_highest_match(
&self,
tag: &AtomTag,
req: &VersionReq,
transport: Option<&mut T>,
) -> Option<(Version, Id)> { ... }
fn remote_atoms(
&self,
transport: Option<&mut T>,
) -> HashMap<AtomTag, (Version, Id)> { ... }
}
Expand description
A trait for querying version information about atoms in remote stores.
This trait extends QueryStore
to provide high-level operations for working
with atom versions. It enables efficient querying and filtering of atom versions
based on tags and semantic version requirements.
§Key Features
- Atom Discovery: Automatically discovers all atoms in the store using the standard reference pattern
- Version Filtering: Find atoms matching specific tags and version requirements
- Semantic Versioning: Full support for semantic version constraints and comparison
- Type Safety: Strongly typed atom identifiers and version information
§Architecture
The trait builds on top of QueryStore
to provide:
- Low-level reference querying (from QueryStore)
- Atom reference parsing and unpacking
- Version-based filtering and selection
- Semantic version constraint matching
§Use Cases
- Dependency Resolution: Find the highest version of an atom matching version requirements
- Atom Discovery: Enumerate all available atoms in a store
- Version Management: Check for atom updates and new versions
- Lock File Generation: Resolve atom versions for reproducible builds
§Examples
use atom::AtomTag;
use atom::store::{QueryStore, QueryVersion};
use gix::Url;
use semver::VersionReq;
// Query for atoms in a remote store
let url = gix::url::parse("https://github.com/example/atoms.git".into())?;
// Get all available atoms
let atoms = url.get_atoms(None)?;
for (tag, version, id) in atoms {
println!("Atom: {} v{} -> {}", tag, version, id);
}
// Find the highest version matching a requirement
let req = VersionReq::parse(">=1.0.0,<2.0.0")?;
if let Some((version, id)) = url.get_highest_match(&AtomTag::try_from("mylib")?, &req, None) {
println!("Selected version {} with id {}", version, id);
}
Provided Methods§
Sourcefn process_atoms(
refs: impl IntoIterator<Item = Ref>,
) -> <C as IntoIterator>::IntoIter
fn process_atoms( refs: impl IntoIterator<Item = Ref>, ) -> <C as IntoIterator>::IntoIter
Hello world
Sourcefn get_atoms(
&self,
transport: Option<&mut T>,
) -> Result<<C as IntoIterator>::IntoIter, <Self as QueryStore<Ref, T>>::Error>
fn get_atoms( &self, transport: Option<&mut T>, ) -> Result<<C as IntoIterator>::IntoIter, <Self as QueryStore<Ref, T>>::Error>
Retrieves all atoms available in the remote store.
This method queries the store for all atom references using the standard
refs/atoms/*
pattern and unpacks them into structured atom information.
§Returns
An iterator over all discovered atoms, where each atom contains:
AtomTag
: The atom’s identifier/tag nameVersion
: The semantic version of the atomId
: The unique identifier for this atom version
§Errors
Returns an error if the reference query fails or if reference parsing fails.
Sourcefn process_highest_match(
atoms: <C as IntoIterator>::IntoIter,
tag: &AtomTag,
req: &VersionReq,
) -> Option<(Version, Id)>
fn process_highest_match( atoms: <C as IntoIterator>::IntoIter, tag: &AtomTag, req: &VersionReq, ) -> Option<(Version, Id)>
foobar
Sourcefn process_root(atoms: <C as IntoIterator>::IntoIter) -> Option<Id>
fn process_root(atoms: <C as IntoIterator>::IntoIter) -> Option<Id>
find the root commit of the remote repo
Sourcefn get_highest_match(
&self,
tag: &AtomTag,
req: &VersionReq,
transport: Option<&mut T>,
) -> Option<(Version, Id)>
fn get_highest_match( &self, tag: &AtomTag, req: &VersionReq, transport: Option<&mut T>, ) -> Option<(Version, Id)>
Finds the highest version of an atom matching the given version requirement.
This method searches through all available atom versions for a specific tag and returns the highest version that satisfies the provided version requirement. Uses semantic version comparison to determine “highest” version.
§Arguments
tag
- The atom tag to search for (e.g., “mylib”, “database”)req
- The version requirement to match (e.g., “>=1.0.0”, “~2.1.0”)
§Returns
The highest matching version and its identifier, or None
if no versions match.
§Examples
use atom::AtomTag;
use atom::store::QueryVersion;
use semver::VersionReq;
let url = gix::url::parse("https://example.com/my-repo.git".into())?;
let req = VersionReq::parse(">=1.0.0,<2.0.0")?;
let result = url.get_highest_match(&AtomTag::try_from("mylib")?, &req, None);
Sourcefn remote_atoms(
&self,
transport: Option<&mut T>,
) -> HashMap<AtomTag, (Version, Id)>
fn remote_atoms( &self, transport: Option<&mut T>, ) -> HashMap<AtomTag, (Version, Id)>
Retrieves all atoms from the remote store and maps them by their tag.
This method provides a convenient way to get a comprehensive overview of all
atoms available in the remote store, organized by their unique AtomTag
.
If an atom has multiple versions, only the highest version is returned.
§Returns
A HashMap
where:
- The key is the
AtomTag
, representing the unique identifier of the atom. - The value is a tuple containing the
Version
andId
of the atom.
If the remote store cannot be reached or if there are no atoms, an empty
HashMap
is returned.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.