diff --git a/components/datetime/tests/data/blob.postcard b/components/datetime/tests/data/blob.postcard index 4ab10b1ebbf..bc2916e45c7 100644 Binary files a/components/datetime/tests/data/blob.postcard and b/components/datetime/tests/data/blob.postcard differ diff --git a/components/datetime/tests/data/gen.sh b/components/datetime/tests/data/gen.sh index 923d898699a..51c780a84a7 100755 --- a/components/datetime/tests/data/gen.sh +++ b/components/datetime/tests/data/gen.sh @@ -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 \ No newline at end of file diff --git a/provider/blob/README.md b/provider/blob/README.md index 9ac94d5de39..ad45767c647 100644 --- a/provider/blob/README.md +++ b/provider/blob/README.md @@ -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 diff --git a/provider/blob/src/export/mod.rs b/provider/blob/src/export/mod.rs index 546ee4bb6f0..2b58ee17298 100644 --- a/provider/blob/src/export/mod.rs +++ b/provider/blob/src/export/mod.rs @@ -17,7 +17,7 @@ //! let mut blob: Vec = 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() @@ -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: diff --git a/provider/blob/src/lib.rs b/provider/blob/src/lib.rs index 967626acafc..bf43aa3374d 100644 --- a/provider/blob/src/lib.rs +++ b/provider/blob/src/lib.rs @@ -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 diff --git a/provider/datagen/README.md b/provider/datagen/README.md index e65a71db6e6..009f51aa4a5 100644 --- a/provider/datagen/README.md +++ b/provider/datagen/README.md @@ -24,7 +24,7 @@ DatagenDriver::new() .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(), )), ) diff --git a/provider/datagen/src/lib.rs b/provider/datagen/src/lib.rs index de645fa42ad..ca697e3e3b0 100644 --- a/provider/datagen/src/lib.rs +++ b/provider/datagen/src/lib.rs @@ -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(), //! )), //! ) @@ -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), /// Output a module with baked data at the given location. Baked { @@ -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 {