diff --git a/Cargo.lock b/Cargo.lock index c9f42ce25292e..ed33db0f68801 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -863,6 +863,7 @@ dependencies = [ "serde", "serde_json", "sha2", + "static_assertions", "thiserror", "url", ] @@ -3458,6 +3459,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "strsim" version = "0.10.0" diff --git a/Cargo.toml b/Cargo.toml index 2492f13007f4d..c3d3d1c4197cf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -74,6 +74,7 @@ seahash = { version = "4.1.0" } serde = { version = "1.0.194" } serde_json = { version = "1.0.111" } sha2 = { version = "0.10.8" } +static_assertions = { version = "1.1.0" } tar = { version = "0.4.40" } target-lexicon = { version = "0.12.13" } tempfile = { version = "3.9.0" } diff --git a/crates/distribution-types/Cargo.toml b/crates/distribution-types/Cargo.toml index 4b87d2665d82e..bc89cbd66ca4f 100644 --- a/crates/distribution-types/Cargo.toml +++ b/crates/distribution-types/Cargo.toml @@ -32,5 +32,6 @@ rustc-hash = { workspace = true } serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } sha2 = { workspace = true } +static_assertions = { workspace = true } thiserror = { workspace = true } url = { workspace = true } diff --git a/crates/distribution-types/src/lib.rs b/crates/distribution-types/src/lib.rs index 5a487807feecf..342cd1a98a3a6 100644 --- a/crates/distribution-types/src/lib.rs +++ b/crates/distribution-types/src/lib.rs @@ -37,6 +37,7 @@ use std::path::{Path, PathBuf}; use std::str::FromStr; use anyhow::Result; +use static_assertions::assert_eq_size; use url::Url; use distribution_filename::{DistFilename, SourceDistFilename, WheelFilename}; @@ -147,7 +148,7 @@ pub enum SourceDist { #[derive(Debug, Clone)] pub struct RegistryBuiltDist { pub filename: WheelFilename, - pub file: File, + pub file: Box, pub index: IndexUrl, } @@ -172,7 +173,7 @@ pub struct PathBuiltDist { #[derive(Debug, Clone)] pub struct RegistrySourceDist { pub filename: SourceDistFilename, - pub file: File, + pub file: Box, pub index: IndexUrl, } @@ -201,6 +202,10 @@ pub struct PathSourceDist { pub editable: bool, } +assert_eq_size!(Dist, [u8; 240]); +assert_eq_size!(BuiltDist, [u8; 240]); +assert_eq_size!(SourceDist, [u8; 168]); + impl Dist { /// Create a [`Dist`] for a registry-based distribution. pub fn from_registry(filename: DistFilename, file: File, index: IndexUrl) -> Self { @@ -208,14 +213,14 @@ impl Dist { DistFilename::WheelFilename(filename) => { Self::Built(BuiltDist::Registry(RegistryBuiltDist { filename, - file, + file: Box::new(file), index, })) } DistFilename::SourceDistFilename(filename) => { Self::Source(SourceDist::Registry(RegistrySourceDist { filename, - file, + file: Box::new(file), index, })) } diff --git a/crates/puffin-client/src/flat_index.rs b/crates/puffin-client/src/flat_index.rs index 732fd2f8501ae..120951e8cf075 100644 --- a/crates/puffin-client/src/flat_index.rs +++ b/crates/puffin-client/src/flat_index.rs @@ -221,7 +221,7 @@ impl FlatIndex { let dist = Dist::Built(BuiltDist::Registry(RegistryBuiltDist { filename, - file, + file: Box::new(file), index, })); match distributions.0.entry(version) { @@ -238,7 +238,7 @@ impl FlatIndex { DistFilename::SourceDistFilename(filename) => { let dist = Dist::Source(SourceDist::Registry(RegistrySourceDist { filename: filename.clone(), - file, + file: Box::new(file), index, })); match distributions.0.entry(filename.version.clone()) {