Skip to content
Merged
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
117 changes: 77 additions & 40 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ anyhow = { version = "1.0.42", features = ["backtrace"]}
askama = "0.14.0"
async-stream = "0.3.5"
axum-extra = { version = "0.12.0", features = ["typed-header", "routing", "middleware"] }
bincode = "~2" # bincode is unmaintained, and 3.0 is just a breaking notification
chrono = { version = "0.4.11", default-features = false, features = ["clock", "serde"] }
derive_more = { version = "2.0.0", features = ["display", "deref", "from", "into", "from_str"] }
futures-util = "0.3.5"
Expand All @@ -37,12 +36,14 @@ opentelemetry = "0.31.0"
opentelemetry-otlp = { version = "0.31.0", features = ["grpc-tonic", "metrics"] }
opentelemetry-resource-detectors = "0.10.0"
opentelemetry_sdk = { version = "0.31.0", features = ["rt-tokio"] }
postcard = { version = "1.1.3", features = ["use-std"] }
rand = "0.9"
regex = "1"
reqwest = { version = "0.12", features = ["json", "gzip"] }
sentry = { version = "0.46.0", features = ["panic", "tracing", "tower-http", "anyhow", "backtrace"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
serde_with = "3.4.0"
sqlx = { version = "0.8", features = [ "runtime-tokio", "postgres", "sqlite", "chrono" ] }
strum = { version = "0.27.0", features = ["derive"] }
tempfile = "3.1.0"
Expand Down Expand Up @@ -112,7 +113,7 @@ http = { workspace = true }
# Data serialization and deserialization
serde = { workspace = true }
serde_json = { workspace = true }
bincode = { workspace = true }
postcard = { workspace = true }

# axum dependencies
axum = { version = "0.8.1", features = ["macros"] }
Expand Down
1 change: 0 additions & 1 deletion crates/lib/docs_rs_cargo_metadata/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ edition = "2024"

[dependencies]
anyhow = { workspace = true }
bincode = { workspace = true }
derive_more = { workspace = true }
docs_rs_types = { path = "../docs_rs_types" }
serde = { workspace = true }
Expand Down
41 changes: 9 additions & 32 deletions crates/lib/docs_rs_cargo_metadata/src/metadata.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::{Context, Result};
use docs_rs_types::{Version, VersionReq};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::collections::BTreeMap;

pub struct CargoMetadata {
root: Package,
Expand Down Expand Up @@ -39,7 +39,7 @@ impl CargoMetadata {
}
}

#[derive(Debug, Deserialize, Serialize)]
#[derive(Debug, Deserialize)]
pub struct Package {
pub id: String,
pub name: String,
Expand All @@ -53,7 +53,7 @@ pub struct Package {
pub targets: Vec<Target>,
pub readme: Option<String>,
pub keywords: Vec<String>,
pub features: HashMap<String, Vec<String>>,
pub features: BTreeMap<String, Vec<String>>,
}

impl Package {
Expand Down Expand Up @@ -86,7 +86,7 @@ impl Package {
}
}

#[derive(Debug, Deserialize, Serialize)]
#[derive(Debug, Deserialize)]
pub struct Target {
pub name: String,
#[cfg(not(feature = "testing"))]
Expand All @@ -107,7 +107,7 @@ impl Target {
}
}

#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
pub struct Dependency {
pub name: String,
pub req: VersionReq,
Expand All @@ -116,29 +116,6 @@ pub struct Dependency {
pub optional: bool,
}

impl bincode::Encode for Dependency {
fn encode<E: bincode::enc::Encoder>(
&self,
encoder: &mut E,
) -> Result<(), bincode::error::EncodeError> {
let Self {
name,
req,
kind,
rename,
optional,
} = self;
name.encode(encoder)?;
// FIXME: VersionReq does not implement Encode, so we serialize it to string
// Could be fixable by wrapping VersionReq in a newtype
req.to_string().encode(encoder)?;
kind.encode(encoder)?;
rename.encode(encoder)?;
optional.encode(encoder)?;
Ok(())
}
}

impl Dependency {
#[cfg(feature = "testing")]
pub fn new(name: String, req: VersionReq) -> Dependency {
Expand All @@ -158,25 +135,25 @@ impl Dependency {
}
}

#[derive(Deserialize, Serialize)]
#[derive(Deserialize)]
struct DeserializedMetadata {
packages: Vec<Package>,
resolve: DeserializedResolve,
}

#[derive(Deserialize, Serialize)]
#[derive(Deserialize)]
struct DeserializedResolve {
root: String,
nodes: Vec<DeserializedResolveNode>,
}

#[derive(Deserialize, Serialize)]
#[derive(Deserialize)]
struct DeserializedResolveNode {
id: String,
deps: Vec<DeserializedResolveDep>,
}

#[derive(Deserialize, Serialize)]
#[derive(Deserialize)]
struct DeserializedResolveDep {
pkg: String,
}
Loading
Loading