Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ name = "update_and_get_most_recent_version"
required-features = ["git-https"]

[dependencies]
gix = { version = "0.73.0", default-features = false, features = [
gix = { version = "0.74.1", default-features = false, features = [
"max-performance-safe",
"blocking-network-client",
"revision",
Expand All @@ -57,7 +57,7 @@ toml = { version = "0.9.0", default-features = false, features = ["parse", "serd
document-features = { version = "0.2.0", optional = true }

[dev-dependencies]
bytesize = "1.2.0"
bytesize = "2.1.0"
cap = { version = "0.1.2", features = ["stats"] }
is_ci = "1.1.1"
tempfile = "3.5.0"
Expand Down
4 changes: 1 addition & 3 deletions examples/list_recent_versions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ fn fetch_crate(name: &str, sparse_index: &SparseIndex) -> Result<Option<Crate>,
}

fn names(name: &str) -> Result<impl Iterator<Item = String>, Box<dyn Error>> {
Ok(Names::new(name)
.ok_or_else(|| "Too many hyphens in crate name")?
.take(3))
Ok(Names::new(name).ok_or("Too many hyphens in crate name")?.take(3))
}

/// Create a request to the sparse `index` and parse the response with the side-effect of yielding
Expand Down
16 changes: 8 additions & 8 deletions examples/sparse_http_reqwest.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use crates_index::SparseIndex;
//!
//! **important**:<br>
//! dont forget to enable the **["blocking", "gzip"]** feature of **reqwest**
//!
//! command to run:<br>
//! cargo run --example sparse_http_reqwest -F sparse
//!

///
/// **important**:<br>
/// dont forget to enable the **["blocking", "gzip"]** feature of **reqwest**
///
/// command to run:<br>
/// cargo run --example sparse_http_reqwest -F sparse
///
use crates_index::SparseIndex;

const CRATE_TO_FETCH: &str = "names";

Expand Down
9 changes: 4 additions & 5 deletions examples/sparse_http_ureq.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
//!
//! command to run:<br>
//! cargo run --example sparse_http_ureq -F sparse
//!
use crates_index::SparseIndex;

///
/// command to run:<br>
/// cargo run --example sparse_http_ureq -F sparse
///

const CRATE_TO_FETCH: &str = "inferno";

fn main() {
Expand Down
28 changes: 8 additions & 20 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,23 +238,18 @@ impl Dependency {
}

/// Section in which this dependency was defined
#[derive(Debug, Copy, Clone, Serialize, Deserialize, Eq, PartialEq, Hash)]
#[derive(Debug, Copy, Clone, Serialize, Deserialize, Eq, PartialEq, Hash, Default)]
#[serde(rename_all = "lowercase")]
pub enum DependencyKind {
/// Used at run time
#[default]
Normal,
/// Not fetched and not used, except for when used direclty in a workspace
Dev,
/// Used at build time, not available at run time
Build,
}

impl Default for DependencyKind {
fn default() -> Self {
Self::Normal
}
}

/// A whole crate with all its versions
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct Crate {
Expand All @@ -277,8 +272,7 @@ impl Crate {
let num_versions = bytes.split(is_newline).count();
let mut versions = Vec::with_capacity(num_versions);
for line in bytes.split(is_newline) {
let mut version: Version =
serde_json::from_slice(line).map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
let mut version: Version = serde_json::from_slice(line).map_err(io::Error::other)?;

version.build_data(dedupe);

Expand Down Expand Up @@ -330,10 +324,7 @@ impl Crate {
// the PR we explicitly tell the user their version of cargo is suspect
// these versions are so old (and specific) it shouldn't affect really anyone
2 => {
return Err(io::Error::new(
io::ErrorKind::Other,
"potentially invalid version 2 cache entry found",
));
return Err(io::Error::other("potentially invalid version 2 cache entry found"));
}
version => {
return Err(io::Error::new(
Expand All @@ -347,13 +338,10 @@ impl Crate {
let update = iter.next().ok_or(io::ErrorKind::UnexpectedEof)?;
if let Some(index_version) = index_version {
if update != index_version.as_bytes() {
return Err(io::Error::new(
io::ErrorKind::Other,
format!(
"cache out of date: current index ({index_version}) != cache ({})",
String::from_utf8_lossy(update)
),
));
return Err(io::Error::other(format!(
"cache out of date: current index ({index_version}) != cache ({})",
String::from_utf8_lossy(update)
)));
}
}

Expand Down
Loading