diff --git a/.gitattributes b/.gitattributes index 2caf69082a8..fa7e360eda0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6,7 +6,7 @@ provider/testdata/data/icuexport/** linguist-generated=true ffi/diplomat/c/include/** linguist-generated=true ffi/diplomat/cpp/include/** linguist-generated=true ffi/diplomat/cpp/docs/** linguist-generated=true -ffi/diplomat/js/include//** linguist-generated=true +ffi/diplomat/js/include/** linguist-generated=true ffi/diplomat/js/docs/** linguist-generated=true *.rs.data linguist-language=Rust */**/README.md linguist-generated=true diff --git a/Cargo.lock b/Cargo.lock index 924d0f03fcd..df6a4a113dd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1414,6 +1414,7 @@ dependencies = [ "tinystr 0.7.0", "unicode-bidi", "writeable", + "zerovec", ] [[package]] @@ -1937,12 +1938,10 @@ dependencies = [ "icu_segmenter", "icu_timezone", "lazy_static", - "litemap", "log", "reqwest", "serde", "simple_logger", - "tinystr 0.7.0", "tokio", "toml", "writeable", diff --git a/ffi/diplomat/Cargo.toml b/ffi/diplomat/Cargo.toml index ebe6b98dc49..e12aab5e768 100644 --- a/ffi/diplomat/Cargo.toml +++ b/ffi/diplomat/Cargo.toml @@ -32,12 +32,11 @@ all-features = true skip_optional_dependencies = true # Bench feature gets tested separately and is only relevant for CI. # logging enables a feature of a dependency that has no externally visible API changes -# serde enables dependency features but buffer_provider affects the actual code denylist = ["bench", "logging"] # Please keep the features list in sync with the icu_capi_staticlib/icu_capi_cdylib crates [features] -default = ["any_provider"] +default = [] any_provider = [] buffer_provider = [ "dep:icu_provider_blob", @@ -63,7 +62,7 @@ logging = ["icu_provider/log_error_context", "dep:log"] simple_logger = ["dep:simple_logger"] # meta feature for things we enable by default in C and C++ -cpp_default = ["provider_test", "logging", "simple_logger"] +cpp_default = ["provider_test", "any_provider", "logging", "simple_logger"] # meta feature for things we enable by default in wasm wasm_default = ["buffer_provider", "logging"] @@ -94,6 +93,9 @@ serde = { version = "1.0", default-features = false, optional = true } icu_testdata = { version = "1.0.0", path = "../../provider/testdata", optional = true, features = ["icu_segmenter"] } +# databake +zerovec = { version = "*", path = "../../utils/zerovec" } + # Run `cargo make diplomat-install` to get the right diplomat binary installed # The version here can either be a `version = ".."` spec or `git = "https://github.com/rust-diplomat/diplomat", rev = ".."` # Since this crate is published, Diplomat must be published preceding a new ICU4X release but may use git versions in between diff --git a/ffi/diplomat/build.rs b/ffi/diplomat/build.rs new file mode 100644 index 00000000000..8b418cfe529 --- /dev/null +++ b/ffi/diplomat/build.rs @@ -0,0 +1,14 @@ +// This file is part of ICU4X. For terms of use, please see the file +// called LICENSE at the top level of the ICU4X source tree +// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). + +fn main() { + if std::env::var("ICU4X_FFI_BAKED_ROOT").is_err() { + // Empty data generated with + // cargo run -p icu_datagen --features bin,icu_segmenter -- --format mod --use-separate-crates --keys none --out empty_bake + println!( + "cargo:rustc-env=ICU4X_FFI_BAKED_ROOT={}/empty_bake", + std::env::var("CARGO_MANIFEST_DIR").unwrap() + ); + } +} diff --git a/ffi/diplomat/c/examples/fixeddecimal_tiny/.gitignore b/ffi/diplomat/c/examples/fixeddecimal_tiny/.gitignore index 36fd6b8da6c..2ddcea818e6 100644 --- a/ffi/diplomat/c/examples/fixeddecimal_tiny/.gitignore +++ b/ffi/diplomat/c/examples/fixeddecimal_tiny/.gitignore @@ -5,5 +5,4 @@ optim* *.elf *.o a.out.dSYM -decimal-bn-en.postcard -decimal_bn_en.h +baked diff --git a/ffi/diplomat/c/examples/fixeddecimal_tiny/Makefile b/ffi/diplomat/c/examples/fixeddecimal_tiny/Makefile index 8fa4bbdefd0..1126f41d8fd 100644 --- a/ffi/diplomat/c/examples/fixeddecimal_tiny/Makefile +++ b/ffi/diplomat/c/examples/fixeddecimal_tiny/Makefile @@ -17,51 +17,49 @@ GCC := gcc CLANG := clang-14 LLD := lld-14 +export ICU4X_FFI_BAKED_ROOT = $(dir $(realpath $(lastword $(MAKEFILE_LIST))))baked -../../../../../target/debug/libicu_capi_staticlib.a: $(ALL_RUST) - cargo build -p icu_capi_staticlib --no-default-features --features buffer_provider +../../../../../target/debug/libicu_capi_staticlib.a: $(ALL_RUST) $(ICU4X_FFI_BAKED_ROOT) + cargo build -p icu_capi_staticlib --no-default-features -icu_capi_staticlib_tiny/target/x86_64-unknown-linux-gnu/debug/libicu_capi_staticlib_tiny.a: $(ALL_RUST) +icu_capi_staticlib_tiny/target/x86_64-unknown-linux-gnu/debug/libicu_capi_staticlib_tiny.a: $(ALL_RUST) $(ICU4X_FFI_BAKED_ROOT) cd icu_capi_staticlib_tiny && \ - RUSTFLAGS="-Clinker-plugin-lto -Clinker=$(CLANG) -Ccodegen-units=1 -Clink-arg=-flto -Cpanic=abort" cargo +${ICU4X_NIGHTLY_TOOLCHAIN} panic-abort-build --target x86_64-unknown-linux-gnu + RUSTFLAGS="-Clinker-plugin-lto -Clinker=$(CLANG) -Ccodegen-units=1 -Clink-arg=-flto -Cpanic=abort" cargo +$(ICU4X_NIGHTLY_TOOLCHAIN) panic-abort-build --target x86_64-unknown-linux-gnu -icu_capi_staticlib_tiny/target/x86_64-unknown-linux-gnu/release-opt-size/libicu_capi_staticlib_tiny.a: $(ALL_RUST) +icu_capi_staticlib_tiny/target/x86_64-unknown-linux-gnu/release-opt-size/libicu_capi_staticlib_tiny.a: $(ALL_RUST) $(ICU4X_FFI_BAKED_ROOT) cd icu_capi_staticlib_tiny && \ - RUSTFLAGS="-Clinker-plugin-lto -Clinker=$(CLANG) -Ccodegen-units=1 -Clink-arg=-flto -Cpanic=abort" cargo +${ICU4X_NIGHTLY_TOOLCHAIN} panic-abort-build --target x86_64-unknown-linux-gnu --profile=release-opt-size + RUSTFLAGS="-Clinker-plugin-lto -Clinker=$(CLANG) -Ccodegen-units=1 -Clink-arg=-flto -Cpanic=abort" cargo +$(ICU4X_NIGHTLY_TOOLCHAIN) panic-abort-build --target x86_64-unknown-linux-gnu --profile=release-opt-size -decimal-bn-en.postcard: - cargo run -p icu_datagen --features bin -- --locales en bn --keys "decimal/symbols@1" --cldr-root ../../../../../provider/testdata/data/cldr/ --format blob --out decimal-bn-en.postcard - -decimal_bn_en.h: decimal-bn-en.postcard - xxd -i -C decimal-bn-en.postcard > decimal_bn_en.h +$(ICU4X_FFI_BAKED_ROOT): + cargo run -p icu_datagen --features bin,icu_segmenter -- --locales en bn --keys "decimal/symbols@1" --cldr-root ../../../../../provider/testdata/data/cldr/ --format mod --use-separate-crates --out ${ICU4X_FFI_BAKED_ROOT} # Naive target: no optimizations, full std -optim0.elf: ../../../../../target/debug/libicu_capi_staticlib.a $(ALL_HEADERS) test.c decimal_bn_en.h +optim0.elf: ../../../../../target/debug/libicu_capi_staticlib.a $(ALL_HEADERS) test.c $(GCC) test.c ../../../../../target/debug/libicu_capi_staticlib.a -ldl -lpthread -lm -g -o optim0.elf # optim.elf: gcc with maximum link-time code stripping (gc-sections and strip-all) -optim1.elf: ../../../../../target/debug/libicu_capi_staticlib.a $(ALL_HEADERS) test.c decimal_bn_en.h +optim1.elf: ../../../../../target/debug/libicu_capi_staticlib.a $(ALL_HEADERS) test.c $(GCC) -fdata-sections -ffunction-sections test.c ../../../../../target/debug/libicu_capi_staticlib.a -ldl -lpthread -lm -g -o optim1.elf -Wl,--gc-sections -Wl,--strip-all # optim2.elf: clang single-step with gc-sections -optim2.elf: icu_capi_staticlib_tiny/target/x86_64-unknown-linux-gnu/debug/libicu_capi_staticlib_tiny.a $(ALL_HEADERS) test.c decimal_bn_en.h +optim2.elf: icu_capi_staticlib_tiny/target/x86_64-unknown-linux-gnu/debug/libicu_capi_staticlib_tiny.a $(ALL_HEADERS) test.c $(CLANG) -flto -fdata-sections -ffunction-sections test.c icu_capi_staticlib_tiny/target/x86_64-unknown-linux-gnu/debug/libicu_capi_staticlib_tiny.a -g -o optim2.elf -Wl,--gc-sections -optim3.o: $(ALL_HEADERS) test.c decimal_bn_en.h +optim3.o: $(ALL_HEADERS) test.c $(CLANG) -c -flto=thin -fdata-sections -ffunction-sections --target=x86_64-unknown-linux-gnu test.c -g -o optim3.o # optim3.elf: clang two-step with lld, debug mode optim3.elf: optim3.o icu_capi_staticlib_tiny/target/x86_64-unknown-linux-gnu/debug/libicu_capi_staticlib_tiny.a $(CLANG) -flto=thin -fuse-ld=$(LLD) -L . -o optim3.elf optim3.o icu_capi_staticlib_tiny/target/x86_64-unknown-linux-gnu/debug/libicu_capi_staticlib_tiny.a -Wl,--gc-sections -optim4.o: $(ALL_HEADERS) test.c decimal_bn_en.h +optim4.o: $(ALL_HEADERS) test.c $(CLANG) -c -flto=thin -fdata-sections -ffunction-sections --target=x86_64-unknown-linux-gnu test.c -g -o optim4.o # optim4.elf: clang two-step with lld, release mode with debug symbols optim4.elf: optim4.o icu_capi_staticlib_tiny/target/x86_64-unknown-linux-gnu/release-opt-size/libicu_capi_staticlib_tiny.a $(CLANG) -flto=thin -fuse-ld=$(LLD) -L . -o optim4.elf optim4.o icu_capi_staticlib_tiny/target/x86_64-unknown-linux-gnu/release-opt-size/libicu_capi_staticlib_tiny.a -Wl,--gc-sections -optim5.o: $(ALL_HEADERS) test.c decimal_bn_en.h +optim5.o: $(ALL_HEADERS) test.c $(CLANG) -c -flto=thin -fdata-sections -ffunction-sections --target=x86_64-unknown-linux-gnu test.c -o optim5.o # optim5.elf: clang two-step with lld, release mode stripped of debug symbols diff --git a/ffi/diplomat/c/examples/fixeddecimal_tiny/icu_capi_staticlib_tiny/Cargo.lock b/ffi/diplomat/c/examples/fixeddecimal_tiny/icu_capi_staticlib_tiny/Cargo.lock index cfb43cf00c1..14c45b46fb8 100644 --- a/ffi/diplomat/c/examples/fixeddecimal_tiny/icu_capi_staticlib_tiny/Cargo.lock +++ b/ffi/diplomat/c/examples/fixeddecimal_tiny/icu_capi_staticlib_tiny/Cargo.lock @@ -8,19 +8,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "cobs" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15" - -[[package]] -name = "deduplicating_array" -version = "0.1.3" -dependencies = [ - "serde", -] - [[package]] name = "diplomat" version = "0.4.2" @@ -94,7 +81,6 @@ dependencies = [ "displaydoc", "icu_locid", "icu_provider", - "serde", "tinystr", "writeable", "zerovec", @@ -120,15 +106,13 @@ dependencies = [ "icu_properties", "icu_provider", "icu_provider_adapters", - "icu_provider_blob", "icu_segmenter", - "icu_testdata", "icu_timezone", "log", - "serde", "tinystr", "unicode-bidi", "writeable", + "zerovec", ] [[package]] @@ -141,7 +125,7 @@ dependencies = [ [[package]] name = "icu_collator" -version = "1.0.0" +version = "1.0.1" dependencies = [ "displaydoc", "icu_collections", @@ -149,7 +133,6 @@ dependencies = [ "icu_normalizer", "icu_properties", "icu_provider", - "serde", "smallvec", "utf16_iter", "utf8_iter", @@ -162,7 +145,6 @@ name = "icu_collections" version = "1.0.0" dependencies = [ "displaydoc", - "serde", "yoke", "zerofrom", "zerovec", @@ -182,7 +164,6 @@ dependencies = [ "icu_provider", "icu_timezone", "litemap", - "serde", "smallvec", "tinystr", "writeable", @@ -197,7 +178,6 @@ dependencies = [ "fixed_decimal", "icu_locid", "icu_provider", - "serde", "writeable", ] @@ -205,12 +185,10 @@ dependencies = [ name = "icu_list" version = "1.0.0" dependencies = [ - "deduplicating_array", "displaydoc", "icu_locid", "icu_provider", "regex-automata", - "serde", "writeable", "zerovec", ] @@ -221,7 +199,6 @@ version = "1.0.0" dependencies = [ "displaydoc", "litemap", - "serde", "tinystr", "writeable", "zerovec", @@ -234,7 +211,6 @@ dependencies = [ "displaydoc", "icu_locid", "icu_provider", - "serde", "tinystr", "zerovec", ] @@ -247,7 +223,6 @@ dependencies = [ "icu_collections", "icu_properties", "icu_provider", - "serde", "smallvec", "utf16_iter", "utf8_iter", @@ -264,7 +239,6 @@ dependencies = [ "fixed_decimal", "icu_locid", "icu_provider", - "serde", "zerovec", ] @@ -275,7 +249,6 @@ dependencies = [ "displaydoc", "icu_collections", "icu_provider", - "serde", "unicode-bidi", "zerovec", ] @@ -287,8 +260,6 @@ dependencies = [ "displaydoc", "icu_locid", "icu_provider_macros", - "postcard", - "serde", "stable_deref_trait", "writeable", "yoke", @@ -302,24 +273,11 @@ version = "1.0.0" dependencies = [ "icu_locid", "icu_provider", - "serde", "tinystr", "yoke", "zerovec", ] -[[package]] -name = "icu_provider_blob" -version = "1.0.0" -dependencies = [ - "icu_provider", - "postcard", - "serde", - "writeable", - "yoke", - "zerovec", -] - [[package]] name = "icu_provider_macros" version = "1.0.0" @@ -337,38 +295,10 @@ dependencies = [ "icu_collections", "icu_locid", "icu_provider", - "serde", - "serde_json", "utf8_iter", "zerovec", ] -[[package]] -name = "icu_testdata" -version = "1.0.0" -dependencies = [ - "icu_calendar", - "icu_collator", - "icu_collections", - "icu_datetime", - "icu_decimal", - "icu_list", - "icu_locid", - "icu_locid_transform", - "icu_normalizer", - "icu_plurals", - "icu_properties", - "icu_provider", - "icu_provider_adapters", - "icu_provider_blob", - "icu_segmenter", - "icu_timezone", - "lazy_static", - "litemap", - "tinystr", - "zerovec", -] - [[package]] name = "icu_timezone" version = "1.0.0" @@ -377,25 +307,15 @@ dependencies = [ "icu_calendar", "icu_locid", "icu_provider", - "serde", "tinystr", "zerovec", ] -[[package]] -name = "itoa" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" - [[package]] name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -dependencies = [ - "spin", -] [[package]] name = "libc" @@ -406,9 +326,6 @@ checksum = "5916d2ae698f6de9bfb891ad7a8d65c09d232dc58cc4ac433c7da3b2fd84bc2b" [[package]] name = "litemap" version = "0.6.0" -dependencies = [ - "serde", -] [[package]] name = "log" @@ -425,16 +342,6 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" -[[package]] -name = "postcard" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c2b180dc0bade59f03fd005cb967d3f1e5f69b13922dad0cd6e047cb8af2363" -dependencies = [ - "cobs", - "serde", -] - [[package]] name = "proc-macro2" version = "1.0.32" @@ -488,31 +395,11 @@ dependencies = [ "syn", ] -[[package]] -name = "serde_json" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e466864e431129c7e0d3476b92f20458e5879919a0596c6472738d9fa2d342f8" -dependencies = [ - "itoa", - "ryu", - "serde", -] - [[package]] name = "smallvec" version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1" -dependencies = [ - "serde", -] - -[[package]] -name = "spin" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" [[package]] name = "stable_deref_trait" @@ -564,7 +451,6 @@ name = "tinystr" version = "0.7.0" dependencies = [ "displaydoc", - "serde", "zerovec", ] @@ -649,7 +535,6 @@ dependencies = [ name = "zerovec" version = "0.9.1" dependencies = [ - "serde", "yoke", "zerofrom", "zerovec-derive", diff --git a/ffi/diplomat/c/examples/fixeddecimal_tiny/icu_capi_staticlib_tiny/Cargo.toml b/ffi/diplomat/c/examples/fixeddecimal_tiny/icu_capi_staticlib_tiny/Cargo.toml index 33347a3fbe3..4fa3d885266 100644 --- a/ffi/diplomat/c/examples/fixeddecimal_tiny/icu_capi_staticlib_tiny/Cargo.toml +++ b/ffi/diplomat/c/examples/fixeddecimal_tiny/icu_capi_staticlib_tiny/Cargo.toml @@ -12,7 +12,7 @@ publish = false crate-type = ["staticlib"] [dependencies] -icu_capi = { path = "../../../..", default-features = false, features = ["buffer_provider"] } +icu_capi = { path = "../../../.." } dlmalloc = { version = "0.2", features = ["global"] } [profile.release] diff --git a/ffi/diplomat/c/examples/fixeddecimal_tiny/test.c b/ffi/diplomat/c/examples/fixeddecimal_tiny/test.c index 9a1881f6272..7e597f0d630 100644 --- a/ffi/diplomat/c/examples/fixeddecimal_tiny/test.c +++ b/ffi/diplomat/c/examples/fixeddecimal_tiny/test.c @@ -3,18 +3,12 @@ // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). #include "../../include/ICU4XFixedDecimalFormatter.h" -#include "decimal_bn_en.h" #include #include int main() { ICU4XLocale* locale = ICU4XLocale_create_bn(); - diplomat_result_box_ICU4XDataProvider_ICU4XError provider_result = ICU4XDataProvider_create_from_byte_slice(DECIMAL_BN_EN_POSTCARD, DECIMAL_BN_EN_POSTCARD_LEN); - if (!provider_result.is_ok) { - printf("Failed to create ICU4XDataProvider\n"); - return 1; - } - ICU4XDataProvider* provider = provider_result.ok; + ICU4XDataProvider* provider = ICU4XDataProvider_create_baked(); ICU4XFixedDecimal* decimal = ICU4XFixedDecimal_create_from_u64(1000007); diplomat_result_box_ICU4XFixedDecimalFormatter_ICU4XError fdf_result = diff --git a/ffi/diplomat/c/include/ICU4XDataProvider.h b/ffi/diplomat/c/include/ICU4XDataProvider.h index fd8b35b7877..39d43b2f8e3 100644 --- a/ffi/diplomat/c/include/ICU4XDataProvider.h +++ b/ffi/diplomat/c/include/ICU4XDataProvider.h @@ -30,6 +30,8 @@ diplomat_result_box_ICU4XDataProvider_ICU4XError ICU4XDataProvider_create_from_b ICU4XDataProvider* ICU4XDataProvider_create_empty(); +ICU4XDataProvider* ICU4XDataProvider_create_baked(); + diplomat_result_void_ICU4XError ICU4XDataProvider_fork_by_key(ICU4XDataProvider* self, ICU4XDataProvider* other); diplomat_result_void_ICU4XError ICU4XDataProvider_fork_by_locale(ICU4XDataProvider* self, ICU4XDataProvider* other); diff --git a/ffi/diplomat/cpp/docs/source/provider_ffi.rst b/ffi/diplomat/cpp/docs/source/provider_ffi.rst index fba4764e6ca..494b6063b8d 100644 --- a/ffi/diplomat/cpp/docs/source/provider_ffi.rst +++ b/ffi/diplomat/cpp/docs/source/provider_ffi.rst @@ -38,6 +38,15 @@ See the `Rust documentation for EmptyDataProvider `__ for more information. + .. cpp:function:: static ICU4XDataProvider create_baked() + + Constructs a :cpp:class:`ICU4XDataProvider` containing baked data. + + When compiling the Rust library, set the ``ICU4X_FFI_BAKED_ROOT`` environment variable to the baked data folder. + + If no data is supplied, this behaves like an empty provider. + + .. cpp:function:: diplomat::result fork_by_key(ICU4XDataProvider& other) Creates a provider that tries the current provider and then, if the current provider doesn't support the data key, another provider ``other``. diff --git a/ffi/diplomat/cpp/examples/bidi/Makefile b/ffi/diplomat/cpp/examples/bidi/Makefile index 8b24376617c..b83f78883e2 100644 --- a/ffi/diplomat/cpp/examples/bidi/Makefile +++ b/ffi/diplomat/cpp/examples/bidi/Makefile @@ -16,7 +16,7 @@ $(ALL_HEADERS): ../../../../../target/debug/libicu_capi_staticlib_test.a: $(ALL_RUST) - cargo build -p icu_capi_staticlib --features provider_test + cargo build -p icu_capi_staticlib --features provider_test,any_provider mv ../../../../../target/debug/libicu_capi_staticlib.a ../../../../../target/debug/libicu_capi_staticlib_test.a a.out: ../../../../../target/debug/libicu_capi_staticlib_test.a $(ALL_HEADERS) test.cpp diff --git a/ffi/diplomat/cpp/examples/fixeddecimal_wasm/Makefile b/ffi/diplomat/cpp/examples/fixeddecimal_wasm/Makefile index f105fc3f5a7..c2b24fe8381 100644 --- a/ffi/diplomat/cpp/examples/fixeddecimal_wasm/Makefile +++ b/ffi/diplomat/cpp/examples/fixeddecimal_wasm/Makefile @@ -17,14 +17,14 @@ $(ALL_RUST): $(ALL_HEADERS): ../../../../../target/debug/libicu_capi_staticlib_test.a: $(ALL_RUST) - cargo build -p icu_capi_staticlib -p icu_capi_staticlib --features provider_test + cargo build -p icu_capi_staticlib -p icu_capi_staticlib --features provider_test,any_provider mv ../../../../../target/debug/libicu_capi_staticlib.a ../../../../../target/debug/libicu_capi_staticlib_test.a a.out: ../../../../../target/debug/libicu_capi_staticlib_test.a $(ALL_HEADERS) test.cpp $(CXX) -std=c++17 test.cpp ../../../../../target/debug/libicu_capi_staticlib_test.a -ldl -lpthread -lm -g ../../../../../target/wasm32-unknown-emscripten/release-opt-size/libicu_capi_staticlib_test.a: $(ALL_RUST) - RUSTFLAGS="-Cpanic=abort" cargo +${ICU4X_NIGHTLY_TOOLCHAIN} build --profile=release-opt-size -p icu_capi_staticlib --features provider_test --target wasm32-unknown-emscripten -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort + RUSTFLAGS="-Cpanic=abort" cargo +${ICU4X_NIGHTLY_TOOLCHAIN} build --profile=release-opt-size -p icu_capi_staticlib --features provider_test,any_provider --target wasm32-unknown-emscripten -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort mv ../../../../../target/wasm32-unknown-emscripten/release-opt-size/libicu_capi_staticlib.a ../../../../../target/wasm32-unknown-emscripten/release-opt-size/libicu_capi_staticlib_test.a web-version.html: ../../../../../target/wasm32-unknown-emscripten/release-opt-size/libicu_capi_staticlib_test.a $(ALL_HEADERS) test.cpp diff --git a/ffi/diplomat/cpp/include/ICU4XDataProvider.h b/ffi/diplomat/cpp/include/ICU4XDataProvider.h index fd8b35b7877..39d43b2f8e3 100644 --- a/ffi/diplomat/cpp/include/ICU4XDataProvider.h +++ b/ffi/diplomat/cpp/include/ICU4XDataProvider.h @@ -30,6 +30,8 @@ diplomat_result_box_ICU4XDataProvider_ICU4XError ICU4XDataProvider_create_from_b ICU4XDataProvider* ICU4XDataProvider_create_empty(); +ICU4XDataProvider* ICU4XDataProvider_create_baked(); + diplomat_result_void_ICU4XError ICU4XDataProvider_fork_by_key(ICU4XDataProvider* self, ICU4XDataProvider* other); diplomat_result_void_ICU4XError ICU4XDataProvider_fork_by_locale(ICU4XDataProvider* self, ICU4XDataProvider* other); diff --git a/ffi/diplomat/cpp/include/ICU4XDataProvider.hpp b/ffi/diplomat/cpp/include/ICU4XDataProvider.hpp index 461d2aa25f4..f31f485eace 100644 --- a/ffi/diplomat/cpp/include/ICU4XDataProvider.hpp +++ b/ffi/diplomat/cpp/include/ICU4XDataProvider.hpp @@ -65,6 +65,16 @@ class ICU4XDataProvider { */ static ICU4XDataProvider create_empty(); + /** + * Constructs a [`ICU4XDataProvider`] containing baked data. + * + * When compiling the Rust library, set the `ICU4X_FFI_BAKED_ROOT` + * environment variable to the baked data folder. + * + * If no data is supplied, this behaves like an empty provider. + */ + static ICU4XDataProvider create_baked(); + /** * Creates a provider that tries the current provider and then, if the current provider * doesn't support the data key, another provider `other`. @@ -143,6 +153,9 @@ inline diplomat::result ICU4XDataProvider::create inline ICU4XDataProvider ICU4XDataProvider::create_empty() { return ICU4XDataProvider(capi::ICU4XDataProvider_create_empty()); } +inline ICU4XDataProvider ICU4XDataProvider::create_baked() { + return ICU4XDataProvider(capi::ICU4XDataProvider_create_baked()); +} inline diplomat::result ICU4XDataProvider::fork_by_key(ICU4XDataProvider& other) { auto diplomat_result_raw_out_value = capi::ICU4XDataProvider_fork_by_key(this->inner.get(), other.AsFFIMut()); diplomat::result diplomat_result_out_value; diff --git a/ffi/diplomat/empty_bake/mod.rs b/ffi/diplomat/empty_bake/mod.rs new file mode 100644 index 00000000000..4cfdcf4c476 --- /dev/null +++ b/ffi/diplomat/empty_bake/mod.rs @@ -0,0 +1,2 @@ +// @generated +use :: icu_provider :: prelude :: * ; # [doc = r" Implement [`DataProvider`] on the given struct using the data"] # [doc = r" hardcoded in this module. This allows the struct to be used with"] # [doc = r" `icu`'s `_unstable` constructors."] # [doc = r""] # [doc = r" This macro can only be called from its definition-site, i.e. right"] # [doc = r" after `include!`-ing the generated module."] # [doc = r""] # [doc = r" ```compile_fail"] # [doc = r" struct MyDataProvider;"] # [doc = r#" include!("/path/to/generated/mod.rs");"#] # [doc = r" impl_data_provider(MyDataProvider);"] # [doc = r" ```"] # [allow (unused_macros)] macro_rules ! impl_data_provider { ($ provider : path) => { } ; ($ provider : path , COMPLETE) => { impl_data_provider ! ($ provider) ; impl DataProvider < :: icu_calendar :: provider :: JapaneseErasV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_calendar :: provider :: JapaneseErasV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_calendar :: provider :: JapaneseErasV1Marker :: KEY , req)) } } impl DataProvider < :: icu_calendar :: provider :: JapaneseExtendedErasV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_calendar :: provider :: JapaneseExtendedErasV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_calendar :: provider :: JapaneseExtendedErasV1Marker :: KEY , req)) } } impl DataProvider < :: icu_calendar :: provider :: WeekDataV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_calendar :: provider :: WeekDataV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_calendar :: provider :: WeekDataV1Marker :: KEY , req)) } } impl DataProvider < :: icu_collator :: provider :: CollationDataV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_collator :: provider :: CollationDataV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_collator :: provider :: CollationDataV1Marker :: KEY , req)) } } impl DataProvider < :: icu_collator :: provider :: CollationDiacriticsV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_collator :: provider :: CollationDiacriticsV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_collator :: provider :: CollationDiacriticsV1Marker :: KEY , req)) } } impl DataProvider < :: icu_collator :: provider :: CollationJamoV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_collator :: provider :: CollationJamoV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_collator :: provider :: CollationJamoV1Marker :: KEY , req)) } } impl DataProvider < :: icu_collator :: provider :: CollationMetadataV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_collator :: provider :: CollationMetadataV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_collator :: provider :: CollationMetadataV1Marker :: KEY , req)) } } impl DataProvider < :: icu_collator :: provider :: CollationReorderingV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_collator :: provider :: CollationReorderingV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_collator :: provider :: CollationReorderingV1Marker :: KEY , req)) } } impl DataProvider < :: icu_collator :: provider :: CollationSpecialPrimariesV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_collator :: provider :: CollationSpecialPrimariesV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_collator :: provider :: CollationSpecialPrimariesV1Marker :: KEY , req)) } } impl DataProvider < :: icu_datetime :: provider :: calendar :: BuddhistDateLengthsV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_datetime :: provider :: calendar :: BuddhistDateLengthsV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_datetime :: provider :: calendar :: BuddhistDateLengthsV1Marker :: KEY , req)) } } impl DataProvider < :: icu_datetime :: provider :: calendar :: BuddhistDateSymbolsV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_datetime :: provider :: calendar :: BuddhistDateSymbolsV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_datetime :: provider :: calendar :: BuddhistDateSymbolsV1Marker :: KEY , req)) } } impl DataProvider < :: icu_datetime :: provider :: calendar :: CopticDateLengthsV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_datetime :: provider :: calendar :: CopticDateLengthsV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_datetime :: provider :: calendar :: CopticDateLengthsV1Marker :: KEY , req)) } } impl DataProvider < :: icu_datetime :: provider :: calendar :: CopticDateSymbolsV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_datetime :: provider :: calendar :: CopticDateSymbolsV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_datetime :: provider :: calendar :: CopticDateSymbolsV1Marker :: KEY , req)) } } impl DataProvider < :: icu_datetime :: provider :: calendar :: EthiopianDateLengthsV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_datetime :: provider :: calendar :: EthiopianDateLengthsV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_datetime :: provider :: calendar :: EthiopianDateLengthsV1Marker :: KEY , req)) } } impl DataProvider < :: icu_datetime :: provider :: calendar :: EthiopianDateSymbolsV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_datetime :: provider :: calendar :: EthiopianDateSymbolsV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_datetime :: provider :: calendar :: EthiopianDateSymbolsV1Marker :: KEY , req)) } } impl DataProvider < :: icu_datetime :: provider :: calendar :: GregorianDateLengthsV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_datetime :: provider :: calendar :: GregorianDateLengthsV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_datetime :: provider :: calendar :: GregorianDateLengthsV1Marker :: KEY , req)) } } impl DataProvider < :: icu_datetime :: provider :: calendar :: GregorianDateSymbolsV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_datetime :: provider :: calendar :: GregorianDateSymbolsV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_datetime :: provider :: calendar :: GregorianDateSymbolsV1Marker :: KEY , req)) } } impl DataProvider < :: icu_datetime :: provider :: calendar :: IndianDateLengthsV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_datetime :: provider :: calendar :: IndianDateLengthsV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_datetime :: provider :: calendar :: IndianDateLengthsV1Marker :: KEY , req)) } } impl DataProvider < :: icu_datetime :: provider :: calendar :: IndianDateSymbolsV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_datetime :: provider :: calendar :: IndianDateSymbolsV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_datetime :: provider :: calendar :: IndianDateSymbolsV1Marker :: KEY , req)) } } impl DataProvider < :: icu_datetime :: provider :: calendar :: JapaneseDateLengthsV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_datetime :: provider :: calendar :: JapaneseDateLengthsV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_datetime :: provider :: calendar :: JapaneseDateLengthsV1Marker :: KEY , req)) } } impl DataProvider < :: icu_datetime :: provider :: calendar :: JapaneseDateSymbolsV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_datetime :: provider :: calendar :: JapaneseDateSymbolsV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_datetime :: provider :: calendar :: JapaneseDateSymbolsV1Marker :: KEY , req)) } } impl DataProvider < :: icu_datetime :: provider :: calendar :: JapaneseExtendedDateLengthsV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_datetime :: provider :: calendar :: JapaneseExtendedDateLengthsV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_datetime :: provider :: calendar :: JapaneseExtendedDateLengthsV1Marker :: KEY , req)) } } impl DataProvider < :: icu_datetime :: provider :: calendar :: JapaneseExtendedDateSymbolsV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_datetime :: provider :: calendar :: JapaneseExtendedDateSymbolsV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_datetime :: provider :: calendar :: JapaneseExtendedDateSymbolsV1Marker :: KEY , req)) } } impl DataProvider < :: icu_datetime :: provider :: calendar :: TimeLengthsV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_datetime :: provider :: calendar :: TimeLengthsV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_datetime :: provider :: calendar :: TimeLengthsV1Marker :: KEY , req)) } } impl DataProvider < :: icu_datetime :: provider :: calendar :: TimeSymbolsV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_datetime :: provider :: calendar :: TimeSymbolsV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_datetime :: provider :: calendar :: TimeSymbolsV1Marker :: KEY , req)) } } impl DataProvider < :: icu_datetime :: provider :: time_zones :: ExemplarCitiesV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_datetime :: provider :: time_zones :: ExemplarCitiesV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_datetime :: provider :: time_zones :: ExemplarCitiesV1Marker :: KEY , req)) } } impl DataProvider < :: icu_datetime :: provider :: time_zones :: MetazoneGenericNamesLongV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_datetime :: provider :: time_zones :: MetazoneGenericNamesLongV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_datetime :: provider :: time_zones :: MetazoneGenericNamesLongV1Marker :: KEY , req)) } } impl DataProvider < :: icu_datetime :: provider :: time_zones :: MetazoneGenericNamesShortV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_datetime :: provider :: time_zones :: MetazoneGenericNamesShortV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_datetime :: provider :: time_zones :: MetazoneGenericNamesShortV1Marker :: KEY , req)) } } impl DataProvider < :: icu_datetime :: provider :: time_zones :: MetazoneSpecificNamesLongV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_datetime :: provider :: time_zones :: MetazoneSpecificNamesLongV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_datetime :: provider :: time_zones :: MetazoneSpecificNamesLongV1Marker :: KEY , req)) } } impl DataProvider < :: icu_datetime :: provider :: time_zones :: MetazoneSpecificNamesShortV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_datetime :: provider :: time_zones :: MetazoneSpecificNamesShortV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_datetime :: provider :: time_zones :: MetazoneSpecificNamesShortV1Marker :: KEY , req)) } } impl DataProvider < :: icu_datetime :: provider :: time_zones :: TimeZoneFormatsV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_datetime :: provider :: time_zones :: TimeZoneFormatsV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_datetime :: provider :: time_zones :: TimeZoneFormatsV1Marker :: KEY , req)) } } impl DataProvider < :: icu_decimal :: provider :: DecimalSymbolsV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_decimal :: provider :: DecimalSymbolsV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_decimal :: provider :: DecimalSymbolsV1Marker :: KEY , req)) } } impl DataProvider < :: icu_list :: provider :: AndListV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_list :: provider :: AndListV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_list :: provider :: AndListV1Marker :: KEY , req)) } } impl DataProvider < :: icu_list :: provider :: OrListV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_list :: provider :: OrListV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_list :: provider :: OrListV1Marker :: KEY , req)) } } impl DataProvider < :: icu_list :: provider :: UnitListV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_list :: provider :: UnitListV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_list :: provider :: UnitListV1Marker :: KEY , req)) } } impl DataProvider < :: icu_locid_transform :: provider :: AliasesV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_locid_transform :: provider :: AliasesV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_locid_transform :: provider :: AliasesV1Marker :: KEY , req)) } } impl DataProvider < :: icu_locid_transform :: provider :: LikelySubtagsV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_locid_transform :: provider :: LikelySubtagsV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_locid_transform :: provider :: LikelySubtagsV1Marker :: KEY , req)) } } impl DataProvider < :: icu_normalizer :: provider :: CanonicalCompositionsV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_normalizer :: provider :: CanonicalCompositionsV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_normalizer :: provider :: CanonicalCompositionsV1Marker :: KEY , req)) } } impl DataProvider < :: icu_normalizer :: provider :: CanonicalDecompositionDataV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_normalizer :: provider :: CanonicalDecompositionDataV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_normalizer :: provider :: CanonicalDecompositionDataV1Marker :: KEY , req)) } } impl DataProvider < :: icu_normalizer :: provider :: CanonicalDecompositionTablesV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_normalizer :: provider :: CanonicalDecompositionTablesV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_normalizer :: provider :: CanonicalDecompositionTablesV1Marker :: KEY , req)) } } impl DataProvider < :: icu_normalizer :: provider :: CompatibilityDecompositionSupplementV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_normalizer :: provider :: CompatibilityDecompositionSupplementV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_normalizer :: provider :: CompatibilityDecompositionSupplementV1Marker :: KEY , req)) } } impl DataProvider < :: icu_normalizer :: provider :: CompatibilityDecompositionTablesV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_normalizer :: provider :: CompatibilityDecompositionTablesV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_normalizer :: provider :: CompatibilityDecompositionTablesV1Marker :: KEY , req)) } } impl DataProvider < :: icu_normalizer :: provider :: NonRecursiveDecompositionSupplementV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_normalizer :: provider :: NonRecursiveDecompositionSupplementV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_normalizer :: provider :: NonRecursiveDecompositionSupplementV1Marker :: KEY , req)) } } impl DataProvider < :: icu_normalizer :: provider :: Uts46DecompositionSupplementV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_normalizer :: provider :: Uts46DecompositionSupplementV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_normalizer :: provider :: Uts46DecompositionSupplementV1Marker :: KEY , req)) } } impl DataProvider < :: icu_plurals :: provider :: CardinalV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_plurals :: provider :: CardinalV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_plurals :: provider :: CardinalV1Marker :: KEY , req)) } } impl DataProvider < :: icu_plurals :: provider :: OrdinalV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_plurals :: provider :: OrdinalV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_plurals :: provider :: OrdinalV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: AlnumV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: AlnumV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: AlnumV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: AlphabeticV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: AlphabeticV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: AlphabeticV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: AsciiHexDigitV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: AsciiHexDigitV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: AsciiHexDigitV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: BasicEmojiV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: BasicEmojiV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: BasicEmojiV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: BidiClassV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: BidiClassV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: BidiClassV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: BidiControlV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: BidiControlV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: BidiControlV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: BidiMirroredV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: BidiMirroredV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: BidiMirroredV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: BlankV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: BlankV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: BlankV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: CanonicalCombiningClassV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: CanonicalCombiningClassV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: CanonicalCombiningClassV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: CaseIgnorableV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: CaseIgnorableV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: CaseIgnorableV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: CaseSensitiveV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: CaseSensitiveV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: CaseSensitiveV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: CasedV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: CasedV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: CasedV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: ChangesWhenCasefoldedV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: ChangesWhenCasefoldedV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: ChangesWhenCasefoldedV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: ChangesWhenCasemappedV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: ChangesWhenCasemappedV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: ChangesWhenCasemappedV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: ChangesWhenLowercasedV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: ChangesWhenLowercasedV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: ChangesWhenLowercasedV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: ChangesWhenNfkcCasefoldedV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: ChangesWhenNfkcCasefoldedV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: ChangesWhenNfkcCasefoldedV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: ChangesWhenTitlecasedV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: ChangesWhenTitlecasedV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: ChangesWhenTitlecasedV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: ChangesWhenUppercasedV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: ChangesWhenUppercasedV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: ChangesWhenUppercasedV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: DashV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: DashV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: DashV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: DefaultIgnorableCodePointV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: DefaultIgnorableCodePointV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: DefaultIgnorableCodePointV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: DeprecatedV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: DeprecatedV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: DeprecatedV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: DiacriticV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: DiacriticV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: DiacriticV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: EastAsianWidthV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: EastAsianWidthV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: EastAsianWidthV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: EmojiComponentV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: EmojiComponentV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: EmojiComponentV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: EmojiModifierBaseV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: EmojiModifierBaseV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: EmojiModifierBaseV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: EmojiModifierV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: EmojiModifierV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: EmojiModifierV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: EmojiPresentationV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: EmojiPresentationV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: EmojiPresentationV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: EmojiV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: EmojiV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: EmojiV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: ExemplarCharactersAuxiliaryV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: ExemplarCharactersAuxiliaryV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: ExemplarCharactersAuxiliaryV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: ExemplarCharactersIndexV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: ExemplarCharactersIndexV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: ExemplarCharactersIndexV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: ExemplarCharactersMainV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: ExemplarCharactersMainV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: ExemplarCharactersMainV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: ExemplarCharactersNumbersV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: ExemplarCharactersNumbersV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: ExemplarCharactersNumbersV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: ExemplarCharactersPunctuationV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: ExemplarCharactersPunctuationV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: ExemplarCharactersPunctuationV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: ExtendedPictographicV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: ExtendedPictographicV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: ExtendedPictographicV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: ExtenderV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: ExtenderV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: ExtenderV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: FullCompositionExclusionV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: FullCompositionExclusionV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: FullCompositionExclusionV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: GeneralCategoryV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: GeneralCategoryV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: GeneralCategoryV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: GraphV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: GraphV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: GraphV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: GraphemeBaseV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: GraphemeBaseV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: GraphemeBaseV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: GraphemeClusterBreakV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: GraphemeClusterBreakV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: GraphemeClusterBreakV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: GraphemeExtendV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: GraphemeExtendV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: GraphemeExtendV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: GraphemeLinkV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: GraphemeLinkV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: GraphemeLinkV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: HexDigitV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: HexDigitV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: HexDigitV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: HyphenV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: HyphenV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: HyphenV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: IdContinueV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: IdContinueV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: IdContinueV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: IdStartV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: IdStartV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: IdStartV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: IdeographicV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: IdeographicV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: IdeographicV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: IdsBinaryOperatorV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: IdsBinaryOperatorV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: IdsBinaryOperatorV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: IdsTrinaryOperatorV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: IdsTrinaryOperatorV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: IdsTrinaryOperatorV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: JoinControlV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: JoinControlV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: JoinControlV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: LineBreakV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: LineBreakV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: LineBreakV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: LogicalOrderExceptionV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: LogicalOrderExceptionV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: LogicalOrderExceptionV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: LowercaseV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: LowercaseV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: LowercaseV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: MathV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: MathV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: MathV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: NfcInertV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: NfcInertV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: NfcInertV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: NfdInertV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: NfdInertV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: NfdInertV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: NfkcInertV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: NfkcInertV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: NfkcInertV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: NfkdInertV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: NfkdInertV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: NfkdInertV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: NoncharacterCodePointV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: NoncharacterCodePointV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: NoncharacterCodePointV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: PatternSyntaxV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: PatternSyntaxV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: PatternSyntaxV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: PatternWhiteSpaceV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: PatternWhiteSpaceV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: PatternWhiteSpaceV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: PrependedConcatenationMarkV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: PrependedConcatenationMarkV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: PrependedConcatenationMarkV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: PrintV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: PrintV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: PrintV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: QuotationMarkV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: QuotationMarkV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: QuotationMarkV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: RadicalV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: RadicalV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: RadicalV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: RegionalIndicatorV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: RegionalIndicatorV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: RegionalIndicatorV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: ScriptV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: ScriptV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: ScriptV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: ScriptWithExtensionsPropertyV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: ScriptWithExtensionsPropertyV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: ScriptWithExtensionsPropertyV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: SegmentStarterV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: SegmentStarterV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: SegmentStarterV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: SentenceBreakV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: SentenceBreakV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: SentenceBreakV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: SentenceTerminalV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: SentenceTerminalV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: SentenceTerminalV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: SoftDottedV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: SoftDottedV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: SoftDottedV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: TerminalPunctuationV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: TerminalPunctuationV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: TerminalPunctuationV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: UnifiedIdeographV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: UnifiedIdeographV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: UnifiedIdeographV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: UppercaseV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: UppercaseV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: UppercaseV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: VariationSelectorV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: VariationSelectorV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: VariationSelectorV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: WhiteSpaceV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: WhiteSpaceV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: WhiteSpaceV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: WordBreakV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: WordBreakV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: WordBreakV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: XdigitV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: XdigitV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: XdigitV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: XidContinueV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: XidContinueV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: XidContinueV1Marker :: KEY , req)) } } impl DataProvider < :: icu_properties :: provider :: XidStartV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_properties :: provider :: XidStartV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_properties :: provider :: XidStartV1Marker :: KEY , req)) } } impl DataProvider < :: icu_provider :: hello_world :: HelloWorldV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_provider :: hello_world :: HelloWorldV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_provider :: hello_world :: HelloWorldV1Marker :: KEY , req)) } } impl DataProvider < :: icu_provider_adapters :: fallback :: provider :: CollationFallbackSupplementV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_provider_adapters :: fallback :: provider :: CollationFallbackSupplementV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_provider_adapters :: fallback :: provider :: CollationFallbackSupplementV1Marker :: KEY , req)) } } impl DataProvider < :: icu_provider_adapters :: fallback :: provider :: LocaleFallbackLikelySubtagsV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_provider_adapters :: fallback :: provider :: LocaleFallbackLikelySubtagsV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_provider_adapters :: fallback :: provider :: LocaleFallbackLikelySubtagsV1Marker :: KEY , req)) } } impl DataProvider < :: icu_provider_adapters :: fallback :: provider :: LocaleFallbackParentsV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_provider_adapters :: fallback :: provider :: LocaleFallbackParentsV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_provider_adapters :: fallback :: provider :: LocaleFallbackParentsV1Marker :: KEY , req)) } } impl DataProvider < :: icu_segmenter :: provider :: GraphemeClusterBreakDataV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_segmenter :: provider :: GraphemeClusterBreakDataV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_segmenter :: provider :: GraphemeClusterBreakDataV1Marker :: KEY , req)) } } impl DataProvider < :: icu_segmenter :: provider :: LineBreakDataV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_segmenter :: provider :: LineBreakDataV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_segmenter :: provider :: LineBreakDataV1Marker :: KEY , req)) } } impl DataProvider < :: icu_segmenter :: provider :: LstmDataV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_segmenter :: provider :: LstmDataV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_segmenter :: provider :: LstmDataV1Marker :: KEY , req)) } } impl DataProvider < :: icu_segmenter :: provider :: SentenceBreakDataV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_segmenter :: provider :: SentenceBreakDataV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_segmenter :: provider :: SentenceBreakDataV1Marker :: KEY , req)) } } impl DataProvider < :: icu_segmenter :: provider :: UCharDictionaryBreakDataV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_segmenter :: provider :: UCharDictionaryBreakDataV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_segmenter :: provider :: UCharDictionaryBreakDataV1Marker :: KEY , req)) } } impl DataProvider < :: icu_segmenter :: provider :: WordBreakDataV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_segmenter :: provider :: WordBreakDataV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_segmenter :: provider :: WordBreakDataV1Marker :: KEY , req)) } } impl DataProvider < :: icu_timezone :: provider :: MetazonePeriodV1Marker > for $ provider { fn load (& self , req : DataRequest ,) -> Result < DataResponse < :: icu_timezone :: provider :: MetazonePeriodV1Marker > , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (:: icu_timezone :: provider :: MetazonePeriodV1Marker :: KEY , req)) } } } ; } # [doc = r" Implement [`AnyProvider`] on the given struct using the data"] # [doc = r" hardcoded in this module. This allows the struct to be used with"] # [doc = r" `icu`'s `_any` constructors."] # [doc = r""] # [doc = r" This macro can only be called from its definition-site, i.e. right"] # [doc = r" after `include!`-ing the generated module."] # [doc = r" "] # [doc = r" ```compile_fail"] # [doc = r" struct MyAnyProvider;"] # [doc = r#" include!("/path/to/generated/mod.rs");"#] # [doc = r" impl_any_provider(MyAnyProvider);"] # [doc = r" ```"] # [allow (unused_macros)] macro_rules ! impl_any_provider { ($ provider : path) => { impl AnyProvider for $ provider { fn load_any (& self , key : DataKey , req : DataRequest) -> Result < AnyResponse , DataError > { Err (DataErrorKind :: MissingDataKey . with_req (key , req)) } } } } # [allow (dead_code)] struct BakedDataProvider ; impl_data_provider ! (BakedDataProvider) ; \ No newline at end of file diff --git a/ffi/diplomat/js/docs/source/provider_ffi.rst b/ffi/diplomat/js/docs/source/provider_ffi.rst index c827a7dcee7..19d305b264b 100644 --- a/ffi/diplomat/js/docs/source/provider_ffi.rst +++ b/ffi/diplomat/js/docs/source/provider_ffi.rst @@ -40,6 +40,15 @@ See the `Rust documentation for EmptyDataProvider `__ for more information. + .. js:function:: create_baked() + + Constructs a :js:class:`ICU4XDataProvider` containing baked data. + + When compiling the Rust library, set the ``ICU4X_FFI_BAKED_ROOT`` environment variable to the baked data folder. + + If no data is supplied, this behaves like an empty provider. + + .. js:function:: fork_by_key(other) Creates a provider that tries the current provider and then, if the current provider doesn't support the data key, another provider ``other``. diff --git a/ffi/diplomat/js/include/ICU4XDataProvider.d.ts b/ffi/diplomat/js/include/ICU4XDataProvider.d.ts index 83cd1f51bce..0b18ab21419 100644 --- a/ffi/diplomat/js/include/ICU4XDataProvider.d.ts +++ b/ffi/diplomat/js/include/ICU4XDataProvider.d.ts @@ -44,6 +44,16 @@ export class ICU4XDataProvider { */ static create_empty(): ICU4XDataProvider; + /** + + * Constructs a {@link ICU4XDataProvider `ICU4XDataProvider`} containing baked data. + + * When compiling the Rust library, set the `ICU4X_FFI_BAKED_ROOT` environment variable to the baked data folder. + + * If no data is supplied, this behaves like an empty provider. + */ + static create_baked(): ICU4XDataProvider; + /** * Creates a provider that tries the current provider and then, if the current provider doesn't support the data key, another provider `other`. diff --git a/ffi/diplomat/js/include/ICU4XDataProvider.js b/ffi/diplomat/js/include/ICU4XDataProvider.js index 3b1354f8248..f129fda425f 100644 --- a/ffi/diplomat/js/include/ICU4XDataProvider.js +++ b/ffi/diplomat/js/include/ICU4XDataProvider.js @@ -64,6 +64,10 @@ export class ICU4XDataProvider { return new ICU4XDataProvider(wasm.ICU4XDataProvider_create_empty(), true, []); } + static create_baked() { + return new ICU4XDataProvider(wasm.ICU4XDataProvider_create_baked(), true, []); + } + fork_by_key(arg_other) { return (() => { const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); diff --git a/ffi/diplomat/src/provider.rs b/ffi/diplomat/src/provider.rs index 8e95b848cbd..b1dd779ff24 100644 --- a/ffi/diplomat/src/provider.rs +++ b/ffi/diplomat/src/provider.rs @@ -14,7 +14,9 @@ use yoke::{trait_hack::YokeTraitHack, Yokeable}; use zerofrom::ZeroFrom; pub enum ICU4XDataProviderInner { + Destroyed, Empty, + Baked, #[cfg(feature = "any_provider")] Any(Box), #[cfg(feature = "buffer_provider")] @@ -23,18 +25,30 @@ pub enum ICU4XDataProviderInner { impl Default for ICU4XDataProviderInner { fn default() -> Self { - Self::Empty + Self::Destroyed } } +struct BakedProvider; +mod baked { + include!(concat!(core::env!("ICU4X_FFI_BAKED_ROOT"), "/mod.rs")); + impl_data_provider!(super::BakedProvider, COMPLETE); + #[cfg(feature = "any_provider")] + impl_any_provider!(super::BakedProvider); +} + #[diplomat::bridge] pub mod ffi { + #[allow(unused_imports)] // feature-gated + use super::BakedProvider; use super::ICU4XDataProviderInner; use crate::errors::ffi::ICU4XError; use crate::fallbacker::ffi::ICU4XLocaleFallbacker; use alloc::boxed::Box; use diplomat_runtime::DiplomatResult; #[allow(unused_imports)] // feature-gated + use icu_provider_adapters::empty::EmptyDataProvider; + #[allow(unused_imports)] // feature-gated use icu_provider_adapters::fallback::LocaleFallbackProvider; #[allow(unused_imports)] // feature-gated use icu_provider_adapters::fork::predicates::MissingLocalePredicate; @@ -46,21 +60,15 @@ pub mod ffi { #[cfg(feature = "any_provider")] #[allow(dead_code)] // feature-specific - fn convert_any_provider( - x: D, - ) -> Box { - Box::new(ICU4XDataProvider( - super::ICU4XDataProviderInner::from_any_provider(x), - )) + fn convert_any_provider(x: D) -> ICU4XDataProvider { + ICU4XDataProvider(super::ICU4XDataProviderInner::Any(Box::new(x))) } #[cfg(feature = "buffer_provider")] fn convert_buffer_provider( x: D, - ) -> Box { - Box::new(ICU4XDataProvider( - super::ICU4XDataProviderInner::from_buffer_provider(x), - )) + ) -> ICU4XDataProvider { + ICU4XDataProvider(super::ICU4XDataProviderInner::Buffer(Box::new(x))) } impl ICU4XDataProvider { @@ -90,6 +98,7 @@ pub mod ffi { icu_provider_fs::FsDataProvider::try_new(path) .map_err(Into::into) .map(convert_buffer_provider) + .map(Box::new) .into() } } @@ -108,14 +117,14 @@ pub mod ffi { panic!("Requires feature 'any_provider' or 'buffer_provider'"); #[cfg(all(feature = "provider_test", feature = "any_provider"))] - return convert_any_provider(icu_testdata::any()); + return Box::new(convert_any_provider(icu_testdata::any())); #[cfg(all( feature = "provider_test", feature = "buffer_provider", not(feature = "any_provider") ))] - return convert_buffer_provider(icu_testdata::buffer()); + return Box::new(convert_buffer_provider(icu_testdata::buffer())); } /// Constructs a `BlobDataProvider` and returns it as an [`ICU4XDataProvider`]. @@ -131,6 +140,7 @@ pub mod ffi { icu_provider_blob::BlobDataProvider::try_new_from_static_blob(blob) .map_err(Into::into) .map(convert_buffer_provider) + .map(Box::new) .into() } @@ -145,6 +155,16 @@ pub mod ffi { Box::new(ICU4XDataProvider(ICU4XDataProviderInner::Empty)) } + /// Constructs a [`ICU4XDataProvider`] containing baked data. + /// + /// When compiling the Rust library, set the `ICU4X_FFI_BAKED_ROOT` + /// environment variable to the baked data folder. + /// + /// If no data is supplied, this behaves like an empty provider. + pub fn create_baked() -> Box { + Box::new(ICU4XDataProvider(ICU4XDataProviderInner::Baked)) + } + /// Creates a provider that tries the current provider and then, if the current provider /// doesn't support the data key, another provider `other`. /// @@ -163,22 +183,36 @@ pub mod ffi { &mut self, other: &mut ICU4XDataProvider, ) -> DiplomatResult<(), ICU4XError> { - let a = core::mem::take(&mut self.0); - let b = core::mem::take(&mut other.0); - match (a, b) { + *self = match (core::mem::take(&mut self.0), core::mem::take(&mut other.0)) { + (ICU4XDataProviderInner::Empty, b) | (b, ICU4XDataProviderInner::Empty) => { + ICU4XDataProvider(b) + } + (ICU4XDataProviderInner::Baked, ICU4XDataProviderInner::Baked) => { + ICU4XDataProvider(ICU4XDataProviderInner::Baked) + } + #[cfg(feature = "any_provider")] + (ICU4XDataProviderInner::Any(a), ICU4XDataProviderInner::Baked) => { + convert_any_provider(icu_provider_adapters::fork::ForkByKeyProvider::new( + a, + BakedProvider, + )) + } + #[cfg(feature = "any_provider")] + (ICU4XDataProviderInner::Baked, ICU4XDataProviderInner::Any(b)) => { + convert_any_provider(icu_provider_adapters::fork::ForkByKeyProvider::new( + BakedProvider, + b, + )) + } #[cfg(feature = "any_provider")] (ICU4XDataProviderInner::Any(a), ICU4XDataProviderInner::Any(b)) => { - self.0 = ICU4XDataProviderInner::Any(Box::from( - icu_provider_adapters::fork::ForkByKeyProvider::new(a, b), - )); - Ok(()) + convert_any_provider(icu_provider_adapters::fork::ForkByKeyProvider::new(a, b)) } #[cfg(feature = "buffer_provider")] (ICU4XDataProviderInner::Buffer(a), ICU4XDataProviderInner::Buffer(b)) => { - self.0 = ICU4XDataProviderInner::Buffer(Box::from( - icu_provider_adapters::fork::ForkByKeyProvider::new(a, b), - )); - Ok(()) + convert_buffer_provider(icu_provider_adapters::fork::ForkByKeyProvider::new( + a, b, + )) } _ => { let e = ICU4XError::DataMismatchedAnyBufferError; @@ -186,10 +220,10 @@ pub mod ffi { &"fork_by_key must be passed the same type of provider (Any or Buffer)", e, ); - Err(e) + return Err(e).into(); } - } - .into() + }; + Ok(()).into() } /// Same as `fork_by_key` but forks by locale instead of key. @@ -201,30 +235,52 @@ pub mod ffi { &mut self, other: &mut ICU4XDataProvider, ) -> DiplomatResult<(), ICU4XError> { - let a = core::mem::take(&mut self.0); - let b = core::mem::take(&mut other.0); - match (a, b) { + *self = match (core::mem::take(&mut self.0), core::mem::take(&mut other.0)) { + (ICU4XDataProviderInner::Empty, b) | (b, ICU4XDataProviderInner::Empty) => { + ICU4XDataProvider(b) + } + (ICU4XDataProviderInner::Baked, ICU4XDataProviderInner::Baked) => { + ICU4XDataProvider(ICU4XDataProviderInner::Baked) + } + #[cfg(feature = "any_provider")] + (ICU4XDataProviderInner::Baked, ICU4XDataProviderInner::Any(b)) => { + convert_any_provider( + icu_provider_adapters::fork::ForkByErrorProvider::new_with_predicate( + BakedProvider, + b, + MissingLocalePredicate, + ), + ) + } + #[cfg(feature = "any_provider")] + (ICU4XDataProviderInner::Any(a), ICU4XDataProviderInner::Baked) => { + convert_any_provider( + icu_provider_adapters::fork::ForkByErrorProvider::new_with_predicate( + a, + BakedProvider, + MissingLocalePredicate, + ), + ) + } #[cfg(feature = "any_provider")] (ICU4XDataProviderInner::Any(a), ICU4XDataProviderInner::Any(b)) => { - self.0 = ICU4XDataProviderInner::Any(Box::from( + convert_any_provider( icu_provider_adapters::fork::ForkByErrorProvider::new_with_predicate( a, b, MissingLocalePredicate, ), - )); - Ok(()) + ) } #[cfg(feature = "buffer_provider")] (ICU4XDataProviderInner::Buffer(a), ICU4XDataProviderInner::Buffer(b)) => { - self.0 = ICU4XDataProviderInner::Buffer(Box::from( + convert_buffer_provider( icu_provider_adapters::fork::ForkByErrorProvider::new_with_predicate( a, b, MissingLocalePredicate, ), - )); - Ok(()) + ) } _ => { let e = ICU4XError::DataMismatchedAnyBufferError; @@ -232,10 +288,10 @@ pub mod ffi { &"fork_by_locale must be passed the same type of provider (Any or Buffer)", e, ); - Err(e) + return Err(e).into(); } - } - .into() + }; + Ok(()).into() } /// Enables locale fallbacking for data requests made to this provider. @@ -252,30 +308,34 @@ pub mod ffi { )] pub fn enable_locale_fallback(&mut self) -> DiplomatResult<(), ICU4XError> { match core::mem::take(&mut self.0) { - ICU4XDataProviderInner::Empty => Err(icu_provider::DataErrorKind::MissingDataKey - .into_error() - .into()), + ICU4XDataProviderInner::Destroyed => Err(icu_provider::DataError::custom( + "This provider has been destroyed", + )), + ICU4XDataProviderInner::Empty => { + Ok(ICU4XDataProvider(ICU4XDataProviderInner::Empty)) + } + #[cfg(not(feature = "any_provider"))] + ICU4XDataProviderInner::Baked => panic!( + "Locale fallback for baked providers requires the 'any_provider' feature" + ), + #[cfg(feature = "any_provider")] + ICU4XDataProviderInner::Baked => { + LocaleFallbackProvider::try_new_with_any_provider(BakedProvider) + .map(convert_any_provider) + } #[cfg(feature = "any_provider")] ICU4XDataProviderInner::Any(inner) => { - match LocaleFallbackProvider::try_new_with_any_provider(inner) { - Ok(x) => { - self.0 = ICU4XDataProviderInner::Any(Box::new(x)); - Ok(()) - } - Err(e) => Err(e.into()), - } + LocaleFallbackProvider::try_new_with_any_provider(inner) + .map(convert_any_provider) } #[cfg(feature = "buffer_provider")] ICU4XDataProviderInner::Buffer(inner) => { - match LocaleFallbackProvider::try_new_with_buffer_provider(inner) { - Ok(x) => { - self.0 = ICU4XDataProviderInner::Buffer(Box::new(x)); - Ok(()) - } - Err(e) => Err(e.into()), - } + LocaleFallbackProvider::try_new_with_buffer_provider(inner) + .map(convert_buffer_provider) } } + .map(|p| *self = p) + .map_err(Into::into) .into() } @@ -293,26 +353,35 @@ pub mod ffi { &mut self, fallbacker: &ICU4XLocaleFallbacker, ) -> DiplomatResult<(), ICU4XError> { - match core::mem::take(&mut self.0) { - ICU4XDataProviderInner::Empty => Err(icu_provider::DataErrorKind::MissingDataKey - .into_error() - .into()), + *self = match core::mem::take(&mut self.0) { + ICU4XDataProviderInner::Destroyed => { + return Err( + icu_provider::DataError::custom("This provider has been destroyed").into(), + ) + .into() + } + ICU4XDataProviderInner::Empty => ICU4XDataProvider(ICU4XDataProviderInner::Empty), + #[cfg(not(feature = "any_provider"))] + ICU4XDataProviderInner::Baked => panic!( + "Locale fallback for baked providers requires the 'any_provider' feature" + ), #[cfg(feature = "any_provider")] - ICU4XDataProviderInner::Any(inner) => { - self.0 = ICU4XDataProviderInner::Any(Box::new( - LocaleFallbackProvider::new_with_fallbacker(inner, fallbacker.0.clone()), - )); - Ok(()) + ICU4XDataProviderInner::Baked => { + convert_any_provider(LocaleFallbackProvider::new_with_fallbacker( + BakedProvider, + fallbacker.0.clone(), + )) } + #[cfg(feature = "any_provider")] + ICU4XDataProviderInner::Any(inner) => convert_any_provider( + LocaleFallbackProvider::new_with_fallbacker(inner, fallbacker.0.clone()), + ), #[cfg(feature = "buffer_provider")] - ICU4XDataProviderInner::Buffer(inner) => { - self.0 = ICU4XDataProviderInner::Buffer(Box::new( - LocaleFallbackProvider::new_with_fallbacker(inner, fallbacker.0.clone()), - )); - Ok(()) - } - } - .into() + ICU4XDataProviderInner::Buffer(inner) => convert_buffer_provider( + LocaleFallbackProvider::new_with_fallbacker(inner, fallbacker.0.clone()), + ), + }; + Ok(()).into() } } } @@ -321,9 +390,16 @@ pub mod ffi { impl DataProvider for ICU4XDataProviderInner where M: KeyedDataMarker + 'static, + BakedProvider: DataProvider, { fn load(&self, req: DataRequest) -> Result, DataError> { - EmptyDataProvider::new().load(req) + match self { + ICU4XDataProviderInner::Destroyed => Err(icu_provider::DataError::custom( + "This provider has been destroyed", + )), + ICU4XDataProviderInner::Empty => EmptyDataProvider::new().load(req), + ICU4XDataProviderInner::Baked => BakedProvider.load(req), + } } } @@ -335,10 +411,15 @@ where // for<'de> >::Output: Deserialize<'de>, // Necessary workaround bound (see `yoke::trait_hack` docs): for<'de> YokeTraitHack<>::Output>: serde::Deserialize<'de>, + BakedProvider: DataProvider, { fn load(&self, req: DataRequest) -> Result, DataError> { match self { + ICU4XDataProviderInner::Destroyed => Err(icu_provider::DataError::custom( + "This provider has been destroyed", + )), ICU4XDataProviderInner::Empty => EmptyDataProvider::new().load(req), + ICU4XDataProviderInner::Baked => BakedProvider.load(req), ICU4XDataProviderInner::Buffer(buffer_provider) => { buffer_provider.as_deserializing().load(req) } @@ -353,10 +434,15 @@ where for<'a> YokeTraitHack<>::Output>: Clone, M::Yokeable: ZeroFrom<'static, M::Yokeable>, M::Yokeable: MaybeSendSync, + BakedProvider: DataProvider, { fn load(&self, req: DataRequest) -> Result, DataError> { match self { + ICU4XDataProviderInner::Destroyed => Err(icu_provider::DataError::custom( + "This provider has been destroyed", + )), ICU4XDataProviderInner::Empty => EmptyDataProvider::new().load(req), + ICU4XDataProviderInner::Baked => BakedProvider.load(req), ICU4XDataProviderInner::Any(any_provider) => any_provider.as_downcasting().load(req), } } @@ -373,10 +459,15 @@ where // for<'de> >::Output: Deserialize<'de>, // Necessary workaround bound (see `yoke::trait_hack` docs): for<'de> YokeTraitHack<>::Output>: serde::Deserialize<'de>, + BakedProvider: DataProvider, { fn load(&self, req: DataRequest) -> Result, DataError> { match self { + ICU4XDataProviderInner::Destroyed => Err(icu_provider::DataError::custom( + "This provider has been destroyed", + )), ICU4XDataProviderInner::Empty => EmptyDataProvider::new().load(req), + ICU4XDataProviderInner::Baked => BakedProvider.load(req), ICU4XDataProviderInner::Any(any_provider) => any_provider.as_downcasting().load(req), ICU4XDataProviderInner::Buffer(buffer_provider) => { buffer_provider.as_deserializing().load(req) @@ -384,14 +475,3 @@ where } } } - -impl ICU4XDataProviderInner { - #[cfg(feature = "any_provider")] - fn from_any_provider(any_provider: impl AnyProvider + 'static) -> Self { - Self::Any(Box::new(any_provider)) - } - #[cfg(feature = "buffer_provider")] - fn from_buffer_provider(buffer_provider: impl BufferProvider + 'static) -> Self { - Self::Buffer(Box::new(buffer_provider)) - } -} diff --git a/ffi/gn/Cargo.lock b/ffi/gn/Cargo.lock index b0f672f2242..310dd41b7a4 100644 --- a/ffi/gn/Cargo.lock +++ b/ffi/gn/Cargo.lock @@ -122,6 +122,7 @@ dependencies = [ "tinystr", "unicode-bidi", "writeable", + "zerovec", ] [[package]] diff --git a/ffi/gn/Cargo.toml b/ffi/gn/Cargo.toml index f2f3336e1c4..526ff8c37ba 100644 --- a/ffi/gn/Cargo.toml +++ b/ffi/gn/Cargo.toml @@ -55,3 +55,6 @@ rustflags = ["--cfg=underscore_consts", "--cfg=ptr_addr_of"] [gn.package.syn."1.0.81"] rustflags = [] + +[gn.package.icu_capi."1.0.0"] +rustflags = [] diff --git a/ffi/gn/icu4x/BUILD.gn b/ffi/gn/icu4x/BUILD.gn index 9d72f7c4de6..f2fea36eea7 100644 --- a/ffi/gn/icu4x/BUILD.gn +++ b/ffi/gn/icu4x/BUILD.gn @@ -254,6 +254,7 @@ rust_library("icu_capi-v1_0_0") { deps += [ ":tinystr-v0_7_0" ] deps += [ ":unicode-bidi-v0_3_8" ] deps += [ ":writeable-v0_5_0" ] + deps += [ ":zerovec-v0_9_1" ] if (current_cpu == "wasm32") { deps += [ ":log-v0_4_14" ] } diff --git a/provider/datagen/src/databake.rs b/provider/datagen/src/databake.rs index f3c1c447599..b095ae58c91 100644 --- a/provider/datagen/src/databake.rs +++ b/provider/datagen/src/databake.rs @@ -36,22 +36,12 @@ pub(crate) struct BakedDataExporter { data: Mutex>>>, // All mod.rs files in the module tree. These can only be written after the last flush. mod_files: Mutex>>, - /// Information to generate implementations. This is populated by `flush` and consumed by `close`. - impl_data: Mutex>, + /// Identifiers of the lookup functions for each key. This is populated by `flush` and consumed by `close`. + lookup_idents: Mutex>, // List of dependencies used by baking. dependencies: CrateEnv, } -/// Data required to write the implementations -struct ImplData { - /// The marker of the key - marker: SyncTokenStream, - /// The path to the lookup function for this marker - lookup_ident: SyncTokenStream, - /// The feature gate for the marker - feature: SyncTokenStream, -} - impl BakedDataExporter { pub fn new( mod_directory: PathBuf, @@ -71,7 +61,7 @@ impl BakedDataExporter { use_separate_crates, data: Default::default(), mod_files: Default::default(), - impl_data: Default::default(), + lookup_idents: Default::default(), dependencies: Default::default(), }) } @@ -183,6 +173,30 @@ impl BakedDataExporter { })?; Ok(()) } + + fn feature_gate(&self, marker: &SyncTokenStream, internal: bool) -> TokenStream { + let feature = if !self.insert_feature_gates { + return quote!(); + } else if marker.contains("DateSkeletonPatternsV1Marker") { + "icu_datetime_experimental" + } else { + let feature = marker + .split(" :: ") + .next() + .unwrap() + .strip_prefix(":: ") + .unwrap(); + if feature.starts_with("icu_provider") { + return quote!(); + } + feature + }; + if internal { + quote!(#![cfg(feature = #feature)]) + } else { + quote!(#[cfg(feature = #feature)]) + } + } } impl DataExporter for BakedDataExporter { @@ -205,25 +219,8 @@ impl DataExporter for BakedDataExporter { } fn flush(&self, key: DataKey) -> Result<(), DataError> { - let marker = - syn::parse2::(crate::registry::key_to_marker_bake(key, &self.dependencies)) - .unwrap(); - - let is_datetime_skeletons = - marker.segments.iter().next_back().unwrap().ident == "DateSkeletonPatternsV1Marker"; - - let feature = if !self.insert_feature_gates { - quote!() - } else if is_datetime_skeletons { - quote! { #![cfg(feature = "icu_datetime_experimental")] } - } else { - let feature = marker.segments.iter().next().unwrap().ident.to_string(); - if !feature.starts_with("icu_provider") { - quote! { #![cfg(feature = #feature)] } - } else { - quote!() - } - }; + let marker = crate::registry::key_to_marker_bake(key, &self.dependencies); + let feature = self.feature_gate(&marker.to_string(), true); // Replace non-ident-allowed tokens. This can still fail if a segment starts with // a token that is not allowed in an initial position. @@ -248,7 +245,7 @@ impl DataExporter for BakedDataExporter { path = path.join(level.ident.to_string()); } - let struct_type = if is_datetime_skeletons { + let struct_type = if marker.to_string().contains("DateSkeletonPatternsV1Marker") { quote! { &'static [( &'static [::icu_datetime::fields::Field], @@ -353,11 +350,10 @@ impl DataExporter for BakedDataExporter { false, )?; - self.impl_data.lock().expect("poison").push(ImplData { - marker: quote!(#marker).to_string(), - lookup_ident: quote!(#module_path :: lookup).to_string(), - feature: feature.to_string().replacen("# ! [", "# [", 1), - }); + self.lookup_idents.lock().expect("poison").insert( + quote!(#marker).to_string(), + quote!(#module_path :: lookup).to_string(), + ); Ok(()) } @@ -365,78 +361,104 @@ impl DataExporter for BakedDataExporter { fn close(&mut self) -> Result<(), DataError> { // These are BTreeMaps keyed on the marker to keep the output sorted and stable let mut data_impls = BTreeMap::new(); + let mut non_requested_data_impls = BTreeMap::new(); let mut any_consts = BTreeMap::new(); let mut any_cases = BTreeMap::new(); - for data in move_out!(self.impl_data) - .into_inner() - .expect("poison") + let mut lookup_idents = move_out!(self.lookup_idents).into_inner().expect("poison"); + + for marker in crate::registry::all_keys() .into_iter() + // HelloWorld is the only key not returned by all_keys + .chain(std::iter::once( + icu_provider::hello_world::HelloWorldV1Marker::KEY, + )) + .map(|k| crate::registry::key_to_marker_bake(k, &self.dependencies)) { - let feature = data.feature.parse::().unwrap(); - let marker = data.marker.parse::().unwrap(); - let lookup_ident = data.lookup_ident.parse::().unwrap(); + let marker_str = marker.to_string(); + let feature = self.feature_gate(&marker_str, false); - data_impls.insert(data.marker.clone(), - quote! { - #feature - impl DataProvider<#marker> for $provider { - fn load( - &self, - req: DataRequest, - ) -> Result, DataError> { - #lookup_ident(&req.locale) - .map(zerofrom::ZeroFrom::zero_from) - .map(DataPayload::from_owned) - .map(|payload| { - DataResponse { - metadata: Default::default(), - payload: Some(payload), - } - }) - .ok_or_else(|| DataErrorKind::MissingLocale.with_req(#marker::KEY, req)) + if let Some(lookup_ident) = lookup_idents.remove(&marker_str) { + let lookup_ident = lookup_ident.parse::().unwrap(); + + data_impls.insert(marker_str.clone(), + quote! { + #feature + impl DataProvider<#marker> for $provider { + fn load( + &self, + req: DataRequest, + ) -> Result, DataError> { + #lookup_ident(&req.locale) + .map(zerofrom::ZeroFrom::zero_from) + .map(DataPayload::from_owned) + .map(|payload| { + DataResponse { + metadata: Default::default(), + payload: Some(payload), + } + }) + .ok_or_else(|| DataErrorKind::MissingLocale.with_req(#marker::KEY, req)) + } } - } - }); + }); + + let hash_ident = marker_str + .split(' ') + .next_back() + .unwrap() + .to_ascii_uppercase() + .parse::() + .unwrap(); - let hash_ident = data - .marker - .split(' ') - .next_back() - .unwrap() - .to_ascii_uppercase() - .parse::() - .unwrap(); - any_consts.insert( - data.marker.clone(), - quote! { - #feature - const #hash_ident: ::icu_provider::DataKeyHash = #marker::KEY.hashed(); - }, - ); - any_cases.insert( - data.marker.clone(), - if data.marker - == ":: icu_datetime :: provider :: calendar :: DateSkeletonPatternsV1Marker" - { + any_consts.insert( + marker_str.clone(), quote! { #feature - #hash_ident => { - #lookup_ident(&req.locale) - .map(zerofrom::ZeroFrom::zero_from) - .map(DataPayload::<#marker>::from_owned) - .map(DataPayload::wrap_into_any_payload) + const #hash_ident: ::icu_provider::DataKeyHash = #marker::KEY.hashed(); + }, + ); + any_cases.insert( + marker_str.clone(), + if marker_str + == ":: icu_datetime :: provider :: calendar :: DateSkeletonPatternsV1Marker" + { + quote! { + #feature + #hash_ident => { + #lookup_ident(&req.locale) + .map(zerofrom::ZeroFrom::zero_from) + .map(DataPayload::<#marker>::from_owned) + .map(DataPayload::wrap_into_any_payload) + } } - } - } else { + } else { + quote! { + #feature + #hash_ident => #lookup_ident(&req.locale).map(AnyPayload::from_static_ref), + } + }, + ); + } else { + non_requested_data_impls.insert( + marker_str.clone(), quote! { #feature - #hash_ident => #lookup_ident(&req.locale).map(AnyPayload::from_static_ref), - } - }, - ); + impl DataProvider<#marker> for $provider { + fn load( + &self, + req: DataRequest, + ) -> Result, DataError> { + Err(DataErrorKind::MissingDataKey.with_req(#marker::KEY, req)) + } + } + }, + ); + } } + assert!(lookup_idents.is_empty()); + let any_code = if any_cases.is_empty() { quote! { Err(DataErrorKind::MissingDataKey.with_req(key, req)) @@ -468,6 +490,7 @@ impl DataExporter for BakedDataExporter { .map(|p| p.parse::().unwrap()); let data_impls = data_impls.values(); + let non_requested_data_impls = non_requested_data_impls.values(); self.write_to_file( PathBuf::from("mod"), @@ -494,7 +517,11 @@ impl DataExporter for BakedDataExporter { macro_rules! impl_data_provider { ($provider:path) => { #(#data_impls)* - } + }; + ($provider:path, COMPLETE) => { + impl_data_provider!($provider); + #(#non_requested_data_impls)* + }; } /// Implement [`AnyProvider`] on the given struct using the data @@ -520,6 +547,7 @@ impl DataExporter for BakedDataExporter { } } + #[allow(dead_code)] struct BakedDataProvider; impl_data_provider!(BakedDataProvider); }, diff --git a/provider/datagen/src/registry.rs b/provider/datagen/src/registry.rs index 35cb4f1b832..2f6a3469616 100644 --- a/provider/datagen/src/registry.rs +++ b/provider/datagen/src/registry.rs @@ -26,11 +26,11 @@ use icu_compactdecimal::provider::*; use icu_displaynames::provider::*; #[cfg(feature = "experimental")] use icu_relativetime::provider::*; -#[cfg(feature = "experimental")] +#[cfg(feature = "icu_segmenter")] use icu_segmenter::provider::*; macro_rules! registry { - ($($marker:ident,)+ #[cfg(feature = "experimental")] { $($exp_marker:ident,)+ }) => { + ($($marker:ident,)+ #[cfg(feature = "experimental")] { $($exp_marker:ident,)+ } #[cfg(feature = "icu_segmenter")] { $($seg_marker:ident,)+ }) => { /// List of all supported keys // Excludes the hello world key, as that generally should not be generated. pub fn all_keys() -> Vec { @@ -42,6 +42,10 @@ macro_rules! registry { #[cfg(feature = "experimental")] <$exp_marker>::KEY, )+ + $( + #[cfg(feature = "icu_segmenter")] + <$seg_marker>::KEY, + )+ ] } @@ -52,10 +56,21 @@ macro_rules! registry { HelloWorldV1Marker, $($marker,)+ $($exp_marker,)+ + $($seg_marker,)+ ] ); - #[cfg(not(feature = "experimental"))] + #[cfg(all(feature = "icu_segmenter", not(feature = "experimental")))] + icu_provider::make_exportable_provider!( + crate::DatagenProvider, + [ + HelloWorldV1Marker, + $($marker,)+ + $($seg_marker,)+ + ] + ); + + #[cfg(all(not(feature = "icu_segmenter"), not(feature = "experimental")))] icu_provider::make_exportable_provider!( crate::DatagenProvider, [ @@ -82,6 +97,12 @@ macro_rules! registry { return $exp_marker.bake(env); } )+ + $( + #[cfg(feature = "icu_segmenter")] + if key == $seg_marker::KEY { + return $seg_marker.bake(env); + } + )+ unreachable!("unregistered marker") } } @@ -225,12 +246,6 @@ registry!( DateSkeletonPatternsV1Marker, RegionDisplayNamesV1Marker, LanguageDisplayNamesV1Marker, - GraphemeClusterBreakDataV1Marker, - LineBreakDataV1Marker, - LstmDataV1Marker, - SentenceBreakDataV1Marker, - UCharDictionaryBreakDataV1Marker, - WordBreakDataV1Marker, LongSecondRelativeTimeFormatDataV1Marker, ShortSecondRelativeTimeFormatDataV1Marker, NarrowSecondRelativeTimeFormatDataV1Marker, @@ -258,6 +273,16 @@ registry!( LongCompactDecimalFormatDataV1Marker, ShortCompactDecimalFormatDataV1Marker, } + #[cfg(feature = "icu_segmenter")] + { + GraphemeClusterBreakDataV1Marker, + LineBreakDataV1Marker, + LstmDataV1Marker, + SentenceBreakDataV1Marker, + UCharDictionaryBreakDataV1Marker, + WordBreakDataV1Marker, + } + ); #[test] diff --git a/provider/datagen/src/transform/mod.rs b/provider/datagen/src/transform/mod.rs index d587125ae24..905cdd10562 100644 --- a/provider/datagen/src/transform/mod.rs +++ b/provider/datagen/src/transform/mod.rs @@ -4,7 +4,7 @@ pub mod cldr; pub mod icuexport; -#[cfg(feature = "experimental")] +#[cfg(feature = "icu_segmenter")] pub mod segmenter; use icu_provider::datagen::*; diff --git a/provider/testdata/Cargo.toml b/provider/testdata/Cargo.toml index d987ca9888b..d2c346af3ba 100644 --- a/provider/testdata/Cargo.toml +++ b/provider/testdata/Cargo.toml @@ -67,8 +67,6 @@ writeable = { version = "0.5", path = "../../utils/writeable", optional = true } # databake deps icu_locid = { version = "1.0.0", path = "../../components/locid" } icu_collections = { version = "1.0.0", path = "../../components/collections" } -litemap = { version = "0.6", path = "../../utils/litemap", default-features = false } -tinystr = { version = "0.7", path = "../../utils/tinystr" } zerovec = { version = "0.9", path = "../../utils/zerovec" } # databake options diff --git a/provider/testdata/data/baked/mod.rs b/provider/testdata/data/baked/mod.rs index 6f767f83213..b233e5738ea 100644 --- a/provider/testdata/data/baked/mod.rs +++ b/provider/testdata/data/baked/mod.rs @@ -2197,6 +2197,105 @@ macro_rules! impl_data_provider { } } }; + ($ provider : path , COMPLETE) => { + impl_data_provider!($provider); + #[cfg(feature = "icu_properties")] + impl DataProvider<::icu_properties::provider::AlnumV1Marker> for $provider { + fn load(&self, req: DataRequest) -> Result, DataError> { + Err(DataErrorKind::MissingDataKey.with_req(::icu_properties::provider::AlnumV1Marker::KEY, req)) + } + } + #[cfg(feature = "icu_properties")] + impl DataProvider<::icu_properties::provider::BlankV1Marker> for $provider { + fn load(&self, req: DataRequest) -> Result, DataError> { + Err(DataErrorKind::MissingDataKey.with_req(::icu_properties::provider::BlankV1Marker::KEY, req)) + } + } + #[cfg(feature = "icu_properties")] + impl DataProvider<::icu_properties::provider::CaseSensitiveV1Marker> for $provider { + fn load(&self, req: DataRequest) -> Result, DataError> { + Err(DataErrorKind::MissingDataKey.with_req(::icu_properties::provider::CaseSensitiveV1Marker::KEY, req)) + } + } + #[cfg(feature = "icu_properties")] + impl DataProvider<::icu_properties::provider::ChangesWhenCasemappedV1Marker> for $provider { + fn load(&self, req: DataRequest) -> Result, DataError> { + Err(DataErrorKind::MissingDataKey.with_req(::icu_properties::provider::ChangesWhenCasemappedV1Marker::KEY, req)) + } + } + #[cfg(feature = "icu_properties")] + impl DataProvider<::icu_properties::provider::FullCompositionExclusionV1Marker> for $provider { + fn load(&self, req: DataRequest) -> Result, DataError> { + Err(DataErrorKind::MissingDataKey.with_req(::icu_properties::provider::FullCompositionExclusionV1Marker::KEY, req)) + } + } + #[cfg(feature = "icu_properties")] + impl DataProvider<::icu_properties::provider::GraphV1Marker> for $provider { + fn load(&self, req: DataRequest) -> Result, DataError> { + Err(DataErrorKind::MissingDataKey.with_req(::icu_properties::provider::GraphV1Marker::KEY, req)) + } + } + #[cfg(feature = "icu_properties")] + impl DataProvider<::icu_properties::provider::GraphemeLinkV1Marker> for $provider { + fn load(&self, req: DataRequest) -> Result, DataError> { + Err(DataErrorKind::MissingDataKey.with_req(::icu_properties::provider::GraphemeLinkV1Marker::KEY, req)) + } + } + #[cfg(feature = "icu_properties")] + impl DataProvider<::icu_properties::provider::HyphenV1Marker> for $provider { + fn load(&self, req: DataRequest) -> Result, DataError> { + Err(DataErrorKind::MissingDataKey.with_req(::icu_properties::provider::HyphenV1Marker::KEY, req)) + } + } + #[cfg(feature = "icu_properties")] + impl DataProvider<::icu_properties::provider::NfcInertV1Marker> for $provider { + fn load(&self, req: DataRequest) -> Result, DataError> { + Err(DataErrorKind::MissingDataKey.with_req(::icu_properties::provider::NfcInertV1Marker::KEY, req)) + } + } + #[cfg(feature = "icu_properties")] + impl DataProvider<::icu_properties::provider::NfdInertV1Marker> for $provider { + fn load(&self, req: DataRequest) -> Result, DataError> { + Err(DataErrorKind::MissingDataKey.with_req(::icu_properties::provider::NfdInertV1Marker::KEY, req)) + } + } + #[cfg(feature = "icu_properties")] + impl DataProvider<::icu_properties::provider::NfkcInertV1Marker> for $provider { + fn load(&self, req: DataRequest) -> Result, DataError> { + Err(DataErrorKind::MissingDataKey.with_req(::icu_properties::provider::NfkcInertV1Marker::KEY, req)) + } + } + #[cfg(feature = "icu_properties")] + impl DataProvider<::icu_properties::provider::NfkdInertV1Marker> for $provider { + fn load(&self, req: DataRequest) -> Result, DataError> { + Err(DataErrorKind::MissingDataKey.with_req(::icu_properties::provider::NfkdInertV1Marker::KEY, req)) + } + } + #[cfg(feature = "icu_properties")] + impl DataProvider<::icu_properties::provider::PrependedConcatenationMarkV1Marker> for $provider { + fn load(&self, req: DataRequest) -> Result, DataError> { + Err(DataErrorKind::MissingDataKey.with_req(::icu_properties::provider::PrependedConcatenationMarkV1Marker::KEY, req)) + } + } + #[cfg(feature = "icu_properties")] + impl DataProvider<::icu_properties::provider::PrintV1Marker> for $provider { + fn load(&self, req: DataRequest) -> Result, DataError> { + Err(DataErrorKind::MissingDataKey.with_req(::icu_properties::provider::PrintV1Marker::KEY, req)) + } + } + #[cfg(feature = "icu_properties")] + impl DataProvider<::icu_properties::provider::SegmentStarterV1Marker> for $provider { + fn load(&self, req: DataRequest) -> Result, DataError> { + Err(DataErrorKind::MissingDataKey.with_req(::icu_properties::provider::SegmentStarterV1Marker::KEY, req)) + } + } + #[cfg(feature = "icu_properties")] + impl DataProvider<::icu_properties::provider::XdigitV1Marker> for $provider { + fn load(&self, req: DataRequest) -> Result, DataError> { + Err(DataErrorKind::MissingDataKey.with_req(::icu_properties::provider::XdigitV1Marker::KEY, req)) + } + } + }; } /// Implement [`AnyProvider`] on the given struct using the data /// hardcoded in this module. This allows the struct to be used with @@ -2921,5 +3020,6 @@ macro_rules! impl_any_provider { } }; } +#[allow(dead_code)] struct BakedDataProvider; impl_data_provider!(BakedDataProvider); diff --git a/tools/scripts/tidy.toml b/tools/scripts/tidy.toml index 92c0ede95d8..f2077c871d0 100644 --- a/tools/scripts/tidy.toml +++ b/tools/scripts/tidy.toml @@ -28,7 +28,7 @@ exit_on_error true glob_pattern_array = array "./**/*.rs" "./**/*.yml" "./**/*.toml" "./**/*.rst" "./**/*.bat" "./**/*.c" "./**/*.cpp" # Skip the files matching these patterns. -glob_skip_pattern_array = array "**/target/**/*" "ffi/diplomat/cpp/docs/**/*" "ffi/diplomat/js/docs/**/*" "**/node_modules/**/*" "provider/testdata/data/**/*" "ffi/gn/vendor/**/*" "ffi/gn/third_party_tools/**/*" +glob_skip_pattern_array = array "**/target/**/*" "ffi/diplomat/empty_bake/*" "ffi/diplomat/**/baked/**/*" "ffi/diplomat/cpp/docs/**/*" "ffi/diplomat/js/docs/**/*" "**/node_modules/**/*" "provider/testdata/data/**/*" "ffi/gn/vendor/**/*" "ffi/gn/third_party_tools/**/*" blank_line = set ""