Skip to content

Commit

Permalink
Remove binary files from the released crates.io version (#138)
Browse files Browse the repository at this point in the history
This commit removes the `well_known_types.bin` file from the crates.io
release. Instead of bundling and parsing this file at runtime this
commit hard codes the parsed data structure as rust code. This hopefully
makes it easier to inspect the generated code.
  • Loading branch information
weiznich authored Jan 13, 2025
1 parent 862d6bc commit 547224b
Show file tree
Hide file tree
Showing 7 changed files with 4,525 additions and 9 deletions.
4 changes: 3 additions & 1 deletion prost-reflect/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ exclude = [
"**/tests.rs",
"proptest-regressions",
"src/file_descriptor_set.bin",
"src/well_known_types.bin",
"src/doctest.proto",
"tests"
"tests",
"doc/*.bin",
]

[[test]]
Expand Down
2 changes: 1 addition & 1 deletion prost-reflect/src/descriptor/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl DescriptorPoolOffsets {
}

impl DescriptorPool {
pub(super) fn build_files<I>(&mut self, files: I) -> Result<(), DescriptorError>
pub(crate) fn build_files<I>(&mut self, files: I) -> Result<(), DescriptorError>
where
I: IntoIterator<Item = FileDescriptorProto>,
{
Expand Down
4 changes: 2 additions & 2 deletions prost-reflect/src/descriptor/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use once_cell::sync::Lazy;
use prost::bytes::Buf;
use prost_types::FileDescriptorProto;

use crate::{reflect::WELL_KNOWN_TYPES_BYTES, DescriptorError, DescriptorPool};
use crate::{DescriptorError, DescriptorPool};

static INSTANCE: Lazy<Mutex<DescriptorPool>> =
Lazy::new(|| Mutex::new(DescriptorPool::decode(WELL_KNOWN_TYPES_BYTES).unwrap()));
Lazy::new(|| Mutex::new(crate::reflect::make_wkt_descriptor_pool().unwrap()));

impl DescriptorPool {
/// Gets a copy of the global descriptor pool. By default, this just contains the google well-known types.
Expand Down
2 changes: 1 addition & 1 deletion prost-reflect/src/descriptor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mod global;
mod tag;
#[cfg(test)]
mod tests;
mod types;
pub(crate) mod types;

pub use self::error::DescriptorError;
use self::types::{DescriptorProto, EnumDescriptorProto};
Expand Down
2 changes: 1 addition & 1 deletion prost-reflect/src/descriptor/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ impl<T> Options<T>
where
T: Message + Clone,
{
fn from_prost(options: T) -> Self {
pub(crate) fn from_prost(options: T) -> Self {
Options {
encoded: options.encode_to_vec(),
value: options,
Expand Down
2 changes: 1 addition & 1 deletion prost-reflect/src/reflect/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mod wkt;

pub(crate) use wkt::WELL_KNOWN_TYPES_BYTES;
pub(crate) use wkt::make_wkt_descriptor_pool;

use prost::Message;

Expand Down
4,518 changes: 4,516 additions & 2 deletions prost-reflect/src/reflect/wkt.rs

Large diffs are not rendered by default.

0 comments on commit 547224b

Please sign in to comment.