Skip to content

Commit 1340d22

Browse files
committed
feat(summary): Add unstable pubtime field
1 parent c802c3e commit 1340d22

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/cargo/core/summary.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ struct Inner {
2929
checksum: Option<String>,
3030
links: Option<InternedString>,
3131
rust_version: Option<RustVersion>,
32+
pubtime: Option<jiff::Timestamp>,
3233
}
3334

3435
/// Indicates the dependency inferred from the `dep` syntax that should exist,
@@ -90,6 +91,7 @@ impl Summary {
9091
checksum: None,
9192
links: links.map(|l| l.into()),
9293
rust_version,
94+
pubtime: None,
9395
}),
9496
})
9597
}
@@ -124,6 +126,10 @@ impl Summary {
124126
self.inner.rust_version.as_ref()
125127
}
126128

129+
pub fn pubtime(&self) -> Option<jiff::Timestamp> {
130+
self.inner.pubtime
131+
}
132+
127133
pub fn override_id(mut self, id: PackageId) -> Summary {
128134
Arc::make_mut(&mut self.inner).package_id = id;
129135
self
@@ -133,6 +139,10 @@ impl Summary {
133139
Arc::make_mut(&mut self.inner).checksum = Some(cksum);
134140
}
135141

142+
pub fn set_pubtime(&mut self, pubtime: jiff::Timestamp) {
143+
Arc::make_mut(&mut self.inner).pubtime = Some(pubtime);
144+
}
145+
136146
pub fn map_dependencies<F>(self, mut f: F) -> Summary
137147
where
138148
F: FnMut(Dependency) -> Dependency,

src/cargo/sources/registry/index/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,9 @@ fn index_package_to_summary(pkg: &IndexPackage<'_>, source_id: SourceId) -> Carg
217217
let links: Option<InternedString> = pkg.links.as_ref().map(|l| l.as_ref().into());
218218
let mut summary = Summary::new(pkgid, deps, &features, links, pkg.rust_version.clone())?;
219219
summary.set_checksum(pkg.cksum.clone());
220+
if let Some(pubtime) = pkg.pubtime.as_ref().and_then(|p| p.parse().ok()) {
221+
summary.set_pubtime(pubtime);
222+
}
220223
Ok(summary)
221224
}
222225

0 commit comments

Comments
 (0)