Skip to content

Commit

Permalink
Use Blob2 in more places (#4281)
Browse files Browse the repository at this point in the history
Fixes #4216
  • Loading branch information
sffc authored Nov 14, 2023
1 parent 5774ab6 commit f2d98b1
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 10 deletions.
Binary file modified components/datetime/tests/data/blob.postcard
Binary file not shown.
2 changes: 1 addition & 1 deletion components/datetime/tests/data/gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
cargo run -p icu_datagen -- \
--keys "datetime/gregory/datelengths@1" "datetime/gregory/datesymbols@1" "datetime/timelengths@1" "datetime/timesymbols@1" "decimal/symbols@1" "time_zone/formats@1" "time_zone/specific_short@1" \
--locales en \
--format blob \
--format blob2 \
--out $(dirname $0)/blob.postcard \
--overwrite
6 changes: 3 additions & 3 deletions provider/blob/README.md

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

4 changes: 3 additions & 1 deletion provider/blob/src/export/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//! let mut blob: Vec<u8> = Vec::new();
//!
//! // Set up the exporter
//! let mut exporter = BlobExporter::new_with_sink(Box::new(&mut blob));
//! let mut exporter = BlobExporter::new_v2_with_sink(Box::new(&mut blob));
//!
//! // Export something
//! DatagenDriver::new()
Expand All @@ -27,6 +27,8 @@
//! .unwrap();
//!
//! // communicate the blob to the client application (network, disk, etc.)
//! # let golden_blob = std::fs::read(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/data/v2.postcard")).unwrap();
//! # assert_eq!(blob, golden_blob);
//! ```
//!
//! The resulting blob can now be used like this:
Expand Down
6 changes: 3 additions & 3 deletions provider/blob/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
//! `icu_provider_blob` contains [`BlobDataProvider`], a [`BufferProvider`] implementation that
//! supports loading data from a single serialized blob.
//!
//! To build blob data, use the `--format blob` option of [`icu_datagen`]:
//! To build blob data, use the `--format blob2` option of [`icu_datagen`]:
//!
//! ```bash
//! $ icu4x-datagen --keys all --locales full --format blob --out data.postcard
//! $ icu4x-datagen --keys all --locales full --format blob2 --out data.postcard
//! ```
//!
//! For examples, see the specific data providers.
//! You can also use `--format blob` if you need to support ICU4X versions prior to 1.4.
//!
//! [`ICU4X`]: ../icu/index.html
//! [`BufferProvider`]: icu_provider::BufferProvider
Expand Down
2 changes: 1 addition & 1 deletion provider/datagen/README.md

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

8 changes: 7 additions & 1 deletion provider/datagen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
//! .with_all_locales()
//! .export(
//! &DatagenProvider::new_latest_tested(),
//! BlobExporter::new_with_sink(Box::new(
//! BlobExporter::new_v2_with_sink(Box::new(
//! File::create("data.postcard").unwrap(),
//! )),
//! )
Expand Down Expand Up @@ -468,6 +468,11 @@ pub enum Out {
fingerprint: bool,
},
/// Output as a postcard blob to the given sink.
///
/// This supports only version 1 of the blob format. Please use [`DatagenDriver`] with
/// [`BlobExporter`] to export to blob format version 2.
///
/// [`BlobExporter`]: crate::blob_exporter::BlobExporter
Blob(Box<dyn std::io::Write + Sync>),
/// Output a module with baked data at the given location.
Baked {
Expand Down Expand Up @@ -610,6 +615,7 @@ pub fn datagen(
)?)
}
Out::Blob(write) => {
// Note: no blob v2 support in legacy API
Box::new(blob_exporter::BlobExporter::new_with_sink(write))
}
Out::Baked {
Expand Down

0 comments on commit f2d98b1

Please sign in to comment.