crates_index_diff/index/
mod.rs

1use crate::Index;
2use std::str;
3
4static INDEX_GIT_URL: &str = "https://github.com/rust-lang/crates.io-index";
5static LAST_SEEN_REFNAME: &str = "refs/heads/crates-index-diff_last-seen";
6
7/// Options for cloning the crates-io index.
8pub struct CloneOptions {
9    /// The url to clone the crates-index repository from.
10    pub url: String,
11}
12
13impl Default for CloneOptions {
14    fn default() -> Self {
15        CloneOptions {
16            url: INDEX_GIT_URL.into(),
17        }
18    }
19}
20
21/// Access
22impl Index {
23    /// Return the crates.io repository.
24    pub fn repository(&self) -> &gix::Repository {
25        &self.repo
26    }
27
28    /// Return the crates.io repository, mutably.
29    pub fn repository_mut(&mut self) -> &mut gix::Repository {
30        &mut self.repo
31    }
32
33    /// Return the reference pointing to the state we have seen after calling `fetch_changes()`.
34    pub fn last_seen_reference(
35        &self,
36    ) -> Result<gix::Reference<'_>, gix::reference::find::existing::Error> {
37        self.repo.find_reference(self.seen_ref_name)
38    }
39}
40
41///
42pub mod diff;
43///
44pub mod init;