From bdc0c93179091334f05ec7746ae51f69e79d7a87 Mon Sep 17 00:00:00 2001 From: Robert Bastian Date: Fri, 28 Jun 2024 14:56:49 +0200 Subject: [PATCH 1/2] filter --- ffi/capi/bindings/c/ICU4XDataError.d.h | 11 +- ffi/capi/bindings/cpp/ICU4XDataError.d.hpp | 22 ++- ffi/capi/bindings/cpp/ICU4XDataError.hpp | 1 - ffi/capi/bindings/dart/DataError.g.dart | 2 - ffi/capi/bindings/js/ICU4XDataError.d.ts | 3 - ffi/capi/bindings/js/ICU4XDataError.mjs | 23 ++- ffi/capi/src/errors.rs | 13 +- provider/adapters/src/filter/impls.rs | 170 ++++----------------- provider/adapters/src/filter/mod.rs | 104 +++---------- provider/adapters/src/fork/mod.rs | 40 ++--- provider/core/src/error.rs | 4 - 11 files changed, 103 insertions(+), 290 deletions(-) diff --git a/ffi/capi/bindings/c/ICU4XDataError.d.h b/ffi/capi/bindings/c/ICU4XDataError.d.h index 6873315fd7d..1af10e52803 100644 --- a/ffi/capi/bindings/c/ICU4XDataError.d.h +++ b/ffi/capi/bindings/c/ICU4XDataError.d.h @@ -16,12 +16,11 @@ typedef enum ICU4XDataError { ICU4XDataError_MarkerNotFound = 1, ICU4XDataError_IdentifierNotFound = 2, ICU4XDataError_InvalidRequest = 3, - ICU4XDataError_FilteredResource = 4, - ICU4XDataError_InconsistentData = 5, - ICU4XDataError_Downcast = 6, - ICU4XDataError_Deserialize = 7, - ICU4XDataError_Custom = 8, - ICU4XDataError_Io = 9, + ICU4XDataError_InconsistentData = 4, + ICU4XDataError_Downcast = 5, + ICU4XDataError_Deserialize = 6, + ICU4XDataError_Custom = 7, + ICU4XDataError_Io = 8, } ICU4XDataError; diff --git a/ffi/capi/bindings/cpp/ICU4XDataError.d.hpp b/ffi/capi/bindings/cpp/ICU4XDataError.d.hpp index 5fa62b776e2..188ef02b5fc 100644 --- a/ffi/capi/bindings/cpp/ICU4XDataError.d.hpp +++ b/ffi/capi/bindings/cpp/ICU4XDataError.d.hpp @@ -16,12 +16,11 @@ namespace capi { ICU4XDataError_MarkerNotFound = 1, ICU4XDataError_IdentifierNotFound = 2, ICU4XDataError_InvalidRequest = 3, - ICU4XDataError_FilteredResource = 4, - ICU4XDataError_InconsistentData = 5, - ICU4XDataError_Downcast = 6, - ICU4XDataError_Deserialize = 7, - ICU4XDataError_Custom = 8, - ICU4XDataError_Io = 9, + ICU4XDataError_InconsistentData = 4, + ICU4XDataError_Downcast = 5, + ICU4XDataError_Deserialize = 6, + ICU4XDataError_Custom = 7, + ICU4XDataError_Io = 8, } ICU4XDataError; } @@ -32,12 +31,11 @@ class ICU4XDataError { MarkerNotFound = 1, IdentifierNotFound = 2, InvalidRequest = 3, - FilteredResource = 4, - InconsistentData = 5, - Downcast = 6, - Deserialize = 7, - Custom = 8, - Io = 9, + InconsistentData = 4, + Downcast = 5, + Deserialize = 6, + Custom = 7, + Io = 8, }; ICU4XDataError() = default; diff --git a/ffi/capi/bindings/cpp/ICU4XDataError.hpp b/ffi/capi/bindings/cpp/ICU4XDataError.hpp index 86cd517428c..9d0f75f4472 100644 --- a/ffi/capi/bindings/cpp/ICU4XDataError.hpp +++ b/ffi/capi/bindings/cpp/ICU4XDataError.hpp @@ -30,7 +30,6 @@ inline ICU4XDataError ICU4XDataError::FromFFI(capi::ICU4XDataError c_enum) { case capi::ICU4XDataError_MarkerNotFound: case capi::ICU4XDataError_IdentifierNotFound: case capi::ICU4XDataError_InvalidRequest: - case capi::ICU4XDataError_FilteredResource: case capi::ICU4XDataError_InconsistentData: case capi::ICU4XDataError_Downcast: case capi::ICU4XDataError_Deserialize: diff --git a/ffi/capi/bindings/dart/DataError.g.dart b/ffi/capi/bindings/dart/DataError.g.dart index 6b6a887de66..d162589c4a4 100644 --- a/ffi/capi/bindings/dart/DataError.g.dart +++ b/ffi/capi/bindings/dart/DataError.g.dart @@ -12,8 +12,6 @@ enum DataError { invalidRequest, - filteredResource, - inconsistentData, downcast, diff --git a/ffi/capi/bindings/js/ICU4XDataError.d.ts b/ffi/capi/bindings/js/ICU4XDataError.d.ts index 7118f3e74a3..4367dd41942 100644 --- a/ffi/capi/bindings/js/ICU4XDataError.d.ts +++ b/ffi/capi/bindings/js/ICU4XDataError.d.ts @@ -16,9 +16,6 @@ export enum ICU4XDataError { /** */ InvalidRequest = 'InvalidRequest', - /** - */ - FilteredResource = 'FilteredResource', /** */ InconsistentData = 'InconsistentData', diff --git a/ffi/capi/bindings/js/ICU4XDataError.mjs b/ffi/capi/bindings/js/ICU4XDataError.mjs index 2f3a9aa02a5..745f797d2c6 100644 --- a/ffi/capi/bindings/js/ICU4XDataError.mjs +++ b/ffi/capi/bindings/js/ICU4XDataError.mjs @@ -6,12 +6,11 @@ export const ICU4XDataError_js_to_rust = { "MarkerNotFound": 1, "IdentifierNotFound": 2, "InvalidRequest": 3, - "FilteredResource": 4, - "InconsistentData": 5, - "Downcast": 6, - "Deserialize": 7, - "Custom": 8, - "Io": 9, + "InconsistentData": 4, + "Downcast": 5, + "Deserialize": 6, + "Custom": 7, + "Io": 8, }; export const ICU4XDataError_rust_to_js = { @@ -19,12 +18,11 @@ export const ICU4XDataError_rust_to_js = { [1]: "MarkerNotFound", [2]: "IdentifierNotFound", [3]: "InvalidRequest", - [4]: "FilteredResource", - [5]: "InconsistentData", - [6]: "Downcast", - [7]: "Deserialize", - [8]: "Custom", - [9]: "Io", + [4]: "InconsistentData", + [5]: "Downcast", + [6]: "Deserialize", + [7]: "Custom", + [8]: "Io", }; export const ICU4XDataError = { @@ -32,7 +30,6 @@ export const ICU4XDataError = { "MarkerNotFound": "MarkerNotFound", "IdentifierNotFound": "IdentifierNotFound", "InvalidRequest": "InvalidRequest", - "FilteredResource": "FilteredResource", "InconsistentData": "InconsistentData", "Downcast": "Downcast", "Deserialize": "Deserialize", diff --git a/ffi/capi/src/errors.rs b/ffi/capi/src/errors.rs index 11a992aff9b..c2091b363ad 100644 --- a/ffi/capi/src/errors.rs +++ b/ffi/capi/src/errors.rs @@ -19,12 +19,11 @@ pub mod ffi { MarkerNotFound = 0x01, IdentifierNotFound = 0x02, InvalidRequest = 0x03, - FilteredResource = 0x04, - InconsistentData = 0x05, - Downcast = 0x06, - Deserialize = 0x07, - Custom = 0x08, - Io = 0x09, + InconsistentData = 0x04, + Downcast = 0x05, + Deserialize = 0x06, + Custom = 0x07, + Io = 0x08, } #[derive(Debug, PartialEq, Eq)] @@ -133,7 +132,6 @@ impl From for ICU4XError { DataErrorKind::MarkerNotFound => ICU4XError::DataMissingDataMarkerError, DataErrorKind::IdentifierNotFound => ICU4XError::DataMissingLocaleError, DataErrorKind::InvalidRequest => ICU4XError::DataExtraneousLocaleError, - DataErrorKind::Filtered => ICU4XError::DataFilteredResourceError, DataErrorKind::Downcast(..) => ICU4XError::DataMismatchedTypeError, DataErrorKind::Custom => ICU4XError::DataCustomError, #[cfg(all( @@ -152,7 +150,6 @@ impl From for ICU4XDataError { DataErrorKind::MarkerNotFound => Self::MarkerNotFound, DataErrorKind::IdentifierNotFound => Self::IdentifierNotFound, DataErrorKind::InvalidRequest => Self::InvalidRequest, - DataErrorKind::Filtered => Self::FilteredResource, DataErrorKind::InconsistentData(..) => Self::InconsistentData, DataErrorKind::Downcast(..) => Self::Downcast, DataErrorKind::Deserialize => Self::Deserialize, diff --git a/provider/adapters/src/filter/impls.rs b/provider/adapters/src/filter/impls.rs index 459e038bb22..14f213fab49 100644 --- a/provider/adapters/src/filter/impls.rs +++ b/provider/adapters/src/filter/impls.rs @@ -6,14 +6,22 @@ use super::*; use alloc::boxed::Box; use icu_provider::prelude::*; -use icu_locale::LanguageIdentifier; - -type RequestFilterDataProviderOutput<'a, D> = - RequestFilterDataProvider bool + Sync + 'a>>; +impl FilterDataProvider bool> { + /// Creates a [`FilterDataProvider`] that does not do any filtering. + /// + /// Filters can be added using [`Self::with_filter`]. + pub fn new(provider: D, filter_name: &'static str) -> Self { + Self { + inner: provider, + predicate: |_| true, + filter_name, + } + } +} -impl RequestFilterDataProvider +impl FilterDataProvider where - F: Fn(DataRequest) -> bool + Sync, + F: Fn(DataIdentifierBorrowed) -> bool + Sync, { /// Filter out data requests with certain langids according to the predicate function. The /// predicate should return `true` to allow a langid and `false` to reject a langid. @@ -28,11 +36,10 @@ where /// use icu_locale::{langid, subtags::language}; /// use icu_provider::hello_world::*; /// use icu_provider::prelude::*; - /// use icu_provider_adapters::filter::Filterable; + /// use icu_provider_adapters::filter::FilterDataProvider; /// - /// let provider = HelloWorldProvider - /// .filterable("Demo no-English filter") - /// .filter_by_langid(|langid| langid.language != language!("en")); + /// let provider = FilterDataProvider::new(HelloWorldProvider, "Demo no-English filter") + /// .with_filter(|id| id.locale.language() != language!("en")); /// /// // German requests should succeed: /// let de = DataIdentifierCow::from_locale(langid!("de").into()); @@ -58,7 +65,7 @@ where /// assert!(matches!( /// response, /// Err(DataError { - /// kind: DataErrorKind::Filtered, + /// kind: DataErrorKind::IdentifierNotFound, /// .. /// }) /// )); @@ -70,147 +77,22 @@ where /// assert!(available_ids.contains(&DataIdentifierCow::from_locale(langid!("de").into()))); /// assert!(!available_ids.contains(&DataIdentifierCow::from_locale(langid!("en").into()))); /// ``` - pub fn filter_by_langid<'a>( - self, - predicate: impl Fn(&LanguageIdentifier) -> bool + Sync + 'a, - ) -> RequestFilterDataProviderOutput<'a, D> - where - F: 'a, - { - let old_predicate = self.predicate; - RequestFilterDataProvider { - inner: self.inner, - predicate: Box::new(move |request| -> bool { - if !(old_predicate)(request) { - return false; - } - predicate(&request.id.locale.get_langid()) - }), - filter_name: self.filter_name, - } - } - - /// Filter out data request except those having a language identifier that exactly matches - /// one in the allowlist. - /// - /// This will be replaced with a smarter algorithm for locale filtering; see - /// - /// - /// Data requests with no langid will be allowed. To reject data requests without a langid, - /// chain this with [`Self::require_langid`]. - /// - /// # Examples - /// - /// ``` - /// use icu_locale::langid; - /// use icu_provider::hello_world::*; - /// use icu_provider::prelude::*; - /// use icu_provider_adapters::filter::Filterable; - /// - /// let allowlist = [langid!("de"), langid!("zh")]; - /// let provider = HelloWorldProvider - /// .filterable("Demo German+Chinese filter") - /// .filter_by_langid_allowlist_strict(&allowlist); - /// - /// // German requests should succeed: - /// let de = DataIdentifierCow::from_locale(langid!("de").into()); - /// let response: Result, _> = - /// provider.load(DataRequest { - /// id: de.as_borrowed(), - /// ..Default::default() - /// }); - /// assert!(matches!(response, Ok(_))); - /// - /// // English requests should fail: - /// let en = DataIdentifierCow::from_locale(langid!("en-US").into()); - - /// let response: Result, _> = - /// provider.load(DataRequest { - /// id: en.as_borrowed(), - /// ..Default::default() - /// }); - /// assert!(matches!( - /// response, - /// Err(DataError { - /// kind: DataErrorKind::Filtered, - /// .. - /// }) - /// )); - /// assert_eq!( - /// response.unwrap_err().str_context, - /// Some("Demo German+Chinese filter") - /// ); - /// ``` - pub fn filter_by_langid_allowlist_strict<'a>( + #[allow(clippy::type_complexity)] + pub fn with_filter<'a>( self, - allowlist: &'a [LanguageIdentifier], - ) -> RequestFilterDataProviderOutput<'a, D> - where - F: 'a, - { - let old_predicate = self.predicate; - RequestFilterDataProvider { - inner: self.inner, - predicate: Box::new(move |request| -> bool { - if !(old_predicate)(request) { - return false; - } - request.id.locale.is_langid_und() - || allowlist.contains(&request.id.locale.get_langid()) - }), - filter_name: self.filter_name, - } - } - - /// Require that data requests contain a langid. - /// - /// # Examples - /// - /// ``` - /// use icu_locale::langid; - /// use icu_provider::hello_world::*; - /// use icu_provider::prelude::*; - /// use icu_provider_adapters::filter::Filterable; - /// - /// let provider = HelloWorldProvider - /// .filterable("Demo require-langid filter") - /// .require_langid(); - /// - /// // Requests with a data id should succeed: - /// let id = DataIdentifierCow::from_locale(langid!("de").into()); - /// let response: Result, _> = - /// provider.load(DataRequest { - /// id: id.as_borrowed(), - /// ..Default::default() - /// }); - /// assert!(matches!(response, Ok(_))); - /// - /// // Requests without a data should fail: - /// let response: Result, _> = - /// provider.load(DataRequest { - /// id: Default::default(), - /// ..Default::default() - /// }); - /// assert!(matches!( - /// response, - /// Err(DataError { - /// kind: DataErrorKind::Filtered, - /// .. - /// }) - /// )); - /// ``` - pub fn require_langid<'a>(self) -> RequestFilterDataProviderOutput<'a, D> + predicate: impl Fn(DataIdentifierBorrowed) -> bool + Sync + 'a, + ) -> FilterDataProvider bool + Sync + 'a>> where F: 'a, { let old_predicate = self.predicate; - RequestFilterDataProvider { + FilterDataProvider { inner: self.inner, - predicate: Box::new(move |request| -> bool { - if !(old_predicate)(request) { + predicate: Box::new(move |id| -> bool { + if !(old_predicate)(id) { return false; } - !request.id.locale.is_langid_und() + predicate(id) }), filter_name: self.filter_name, } diff --git a/provider/adapters/src/filter/mod.rs b/provider/adapters/src/filter/mod.rs index 786726518a5..a9b1d2d9436 100644 --- a/provider/adapters/src/filter/mod.rs +++ b/provider/adapters/src/filter/mod.rs @@ -5,18 +5,7 @@ //! Providers that filter resource requests. //! //! Requests that fail a filter test will return [`DataError`] of kind [`Filtered`]( -//! DataErrorKind::Filtered) and will not appear in [`IterableDynamicDataProvider`] iterators. -//! -//! The main struct is [`RequestFilterDataProvider`]. Although that struct can be created -//! directly, the traits in this module provide helper functions for common filtering patterns. -//! -//! To create a `RequestFilterDataProvider`, you can use the [`Filterable`] blanket function: -//! -//! ``` -//! use icu_provider_adapters::filter::Filterable; -//! -//! // now call .filterable() on any object to get a RequestFilterDataProvider -//! ``` +//! DataErrorKind::IdentifierNotFound) and will not appear in [`IterableDynamicDataProvider`] iterators. //! //! # Examples //! @@ -24,12 +13,11 @@ //! use icu_locale::subtags::language; //! use icu_provider::hello_world::*; //! use icu_provider::prelude::*; -//! use icu_provider_adapters::filter::Filterable; +//! use icu_provider_adapters::filter::FilterDataProvider; //! //! // Only return German data from a HelloWorldProvider: -//! HelloWorldProvider -//! .filterable("Demo German-only filter") -//! .filter_by_langid(|langid| langid.language == language!("de")); +//! FilterDataProvider::new(HelloWorldProvider, "Demo German-only filter") +//! .with_filter(|id| id.locale.language() == language!("de")); //! ``` mod impls; @@ -39,16 +27,16 @@ use icu_provider::prelude::*; /// A data provider that selectively filters out data requests. /// /// Data requests that are rejected by the filter will return a [`DataError`] with kind -/// [`Filtered`](DataErrorKind::Filtered), and they will not be returned +/// [`Filtered`](DataErrorKind::IdentifierNotFound), and they will not be returned /// by [`IterableDynamicDataProvider::iter_ids_for_marker`]. /// /// Although this struct can be created directly, the traits in this module provide helper /// functions for common filtering patterns. #[allow(clippy::exhaustive_structs)] // this type is stable #[derive(Debug)] -pub struct RequestFilterDataProvider +pub struct FilterDataProvider where - F: Fn(DataRequest) -> bool, + F: Fn(DataIdentifierBorrowed) -> bool, { /// The data provider to which we delegate requests. pub inner: D, @@ -61,9 +49,9 @@ where pub filter_name: &'static str, } -impl DynamicDataProvider for RequestFilterDataProvider +impl DynamicDataProvider for FilterDataProvider where - F: Fn(DataRequest) -> bool, + F: Fn(DataIdentifierBorrowed) -> bool, M: DynamicDataMarker, D: DynamicDataProvider, { @@ -72,43 +60,43 @@ where marker: DataMarkerInfo, req: DataRequest, ) -> Result, DataError> { - if (self.predicate)(req) { + if (self.predicate)(req.id) { self.inner.load_data(marker, req) } else { - Err(DataErrorKind::Filtered + Err(DataErrorKind::IdentifierNotFound .with_str_context(self.filter_name) .with_req(marker, req)) } } } -impl DataProvider for RequestFilterDataProvider +impl DataProvider for FilterDataProvider where - F: Fn(DataRequest) -> bool, + F: Fn(DataIdentifierBorrowed) -> bool, M: DataMarker, D: DataProvider, { fn load(&self, req: DataRequest) -> Result, DataError> { - if (self.predicate)(req) { + if (self.predicate)(req.id) { self.inner.load(req) } else { - Err(DataErrorKind::Filtered + Err(DataErrorKind::IdentifierNotFound .with_str_context(self.filter_name) .with_req(M::INFO, req)) } } } -impl AnyProvider for RequestFilterDataProvider +impl AnyProvider for FilterDataProvider where - F: Fn(DataRequest) -> bool, + F: Fn(DataIdentifierBorrowed) -> bool, D: AnyProvider, { fn load_any(&self, marker: DataMarkerInfo, req: DataRequest) -> Result { - if (self.predicate)(req) { + if (self.predicate)(req.id) { self.inner.load_any(marker, req) } else { - Err(DataErrorKind::Filtered + Err(DataErrorKind::IdentifierNotFound .with_str_context(self.filter_name) .with_req(marker, req)) } @@ -116,10 +104,10 @@ where } #[cfg(feature = "std")] -impl IterableDynamicDataProvider for RequestFilterDataProvider +impl IterableDynamicDataProvider for FilterDataProvider where M: DynamicDataMarker, - F: Fn(DataRequest) -> bool, + F: Fn(DataIdentifierBorrowed) -> bool, D: IterableDynamicDataProvider, { fn iter_ids_for_marker( @@ -129,67 +117,25 @@ where self.inner.iter_ids_for_marker(marker).map(|set| { // Use filter_map instead of filter to avoid cloning the locale set.into_iter() - .filter(|id| { - (self.predicate)(DataRequest { - id: id.as_borrowed(), - ..Default::default() - }) - }) + .filter(|id| (self.predicate)(id.as_borrowed())) .collect() }) } } #[cfg(feature = "std")] -impl IterableDataProvider for RequestFilterDataProvider +impl IterableDataProvider for FilterDataProvider where M: DataMarker, - F: Fn(DataRequest) -> bool, + F: Fn(DataIdentifierBorrowed) -> bool, D: IterableDataProvider, { fn iter_ids(&self) -> Result, DataError> { self.inner.iter_ids().map(|vec| { // Use filter_map instead of filter to avoid cloning the locale vec.into_iter() - .filter(|id| { - (self.predicate)(DataRequest { - id: id.as_borrowed(), - ..Default::default() - }) - }) + .filter(|id| (self.predicate)(id.as_borrowed())) .collect() }) } } - -/// A blanket-implemented trait exposing the [`Self::filterable()`] function. -/// -/// For more details, see [`icu_provider_adapters::filter`](crate::filter). -pub trait Filterable: Sized { - /// Creates a filterable data provider with the given name for debugging. - /// - /// For more details, see [`icu_provider_adapters::filter`](crate::filter). - fn filterable( - self, - filter_name: &'static str, - ) -> RequestFilterDataProvider bool>; -} - -impl Filterable for T -where - T: Sized, -{ - fn filterable( - self, - filter_name: &'static str, - ) -> RequestFilterDataProvider bool> { - fn noop(_: DataRequest) -> bool { - true - } - RequestFilterDataProvider { - inner: self, - predicate: noop, - filter_name, - } - } -} diff --git a/provider/adapters/src/fork/mod.rs b/provider/adapters/src/fork/mod.rs index 70b53ff369e..b1debd4371c 100644 --- a/provider/adapters/src/fork/mod.rs +++ b/provider/adapters/src/fork/mod.rs @@ -98,18 +98,20 @@ use predicates::MarkerNotFoundPredicate; /// use icu_locale::{subtags::language, langid}; /// use icu_provider::hello_world::*; /// use icu_provider::prelude::*; -/// use icu_provider_adapters::filter::Filterable; +/// use icu_provider_adapters::filter::FilterDataProvider; /// use icu_provider_adapters::fork::ForkByMarkerProvider; /// /// let forking_provider = ForkByMarkerProvider::new( -/// HelloWorldProvider -/// .into_json_provider() -/// .filterable("Chinese") -/// .filter_by_langid(|langid| langid.language == language!("zh")), -/// HelloWorldProvider -/// .into_json_provider() -/// .filterable("German") -/// .filter_by_langid(|langid| langid.language == language!("de")), +/// FilterDataProvider::new( +/// HelloWorldProvider.into_json_provider(), +/// "Chinese" +/// ) +/// .with_filter(|id| id.locale.language() == language!("zh")), +/// FilterDataProvider::new( +/// HelloWorldProvider.into_json_provider(), +/// "German" +/// ) +/// .with_filter(|id| id.locale.language() == language!("de")), /// ); /// /// let provider: &dyn DataProvider = @@ -165,19 +167,21 @@ impl ForkByMarkerProvider { /// use icu_locale::{subtags::language, langid}; /// use icu_provider::hello_world::*; /// use icu_provider::prelude::*; -/// use icu_provider_adapters::filter::Filterable; +/// use icu_provider_adapters::filter::FilterDataProvider; /// use icu_provider_adapters::fork::MultiForkByMarkerProvider; /// /// let forking_provider = MultiForkByMarkerProvider::new( /// vec![ -/// HelloWorldProvider -/// .into_json_provider() -/// .filterable("Chinese") -/// .filter_by_langid(|langid| langid.language == language!("zh")), -/// HelloWorldProvider -/// .into_json_provider() -/// .filterable("German") -/// .filter_by_langid(|langid| langid.language == language!("de")), +/// FilterDataProvider::new( +/// HelloWorldProvider.into_json_provider(), +/// "Chinese" +/// ) +/// .with_filter(|id| id.locale.language() == language!("zh")), +/// FilterDataProvider::new( +/// HelloWorldProvider.into_json_provider(), +/// "German" +/// ) +/// .with_filter(|id| id.locale.language() == language!("de")), /// ], /// ); /// diff --git a/provider/core/src/error.rs b/provider/core/src/error.rs index 3a0ef9d21e0..e504594e118 100644 --- a/provider/core/src/error.rs +++ b/provider/core/src/error.rs @@ -26,10 +26,6 @@ pub enum DataErrorKind { #[displaydoc("Invalid request")] InvalidRequest, - /// The request was blocked by a filter. The data may or may not be available. - #[displaydoc("Request blocked by filter")] - Filtered, - /// The data for two [`DataMarker`]s is not consistent. #[displaydoc("The data for two markers is not consistent: {0:?} (were they generated in different datagen invocations?)")] InconsistentData(DataMarkerInfo), From 6dfece792693ee2edc49816729c8bec554e57506 Mon Sep 17 00:00:00 2001 From: Robert Bastian Date: Fri, 28 Jun 2024 15:57:07 +0200 Subject: [PATCH 2/2] fix --- provider/adapters/src/filter/impls.rs | 3 --- tools/ffi_coverage/src/allowlist.rs | 7 ++----- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/provider/adapters/src/filter/impls.rs b/provider/adapters/src/filter/impls.rs index 14f213fab49..a28b385d6e3 100644 --- a/provider/adapters/src/filter/impls.rs +++ b/provider/adapters/src/filter/impls.rs @@ -26,9 +26,6 @@ where /// Filter out data requests with certain langids according to the predicate function. The /// predicate should return `true` to allow a langid and `false` to reject a langid. /// - /// Data requests with no langid will be allowed. To reject data requests without a langid, - /// chain this with [`Self::require_langid`]. - /// /// # Examples /// /// ``` diff --git a/tools/ffi_coverage/src/allowlist.rs b/tools/ffi_coverage/src/allowlist.rs index 49383c85a44..3e65b780c78 100644 --- a/tools/ffi_coverage/src/allowlist.rs +++ b/tools/ffi_coverage/src/allowlist.rs @@ -284,11 +284,8 @@ lazy_static::lazy_static! { "icu_provider_adapters::any_payload::AnyPayloadProvider", // Not planned for 2.0 - // On RequestFilterDataProvider, filter_by_langid needs callbacks, and - // filter_by_langid_allowlist_strict needs input iterators. - // require_langid is not very useful by itself. - "icu_provider_adapters::filter::Filterable", - "icu_provider_adapters::filter::RequestFilterDataProvider", + // FilterDataProvider::with_filter needs callbacks. + "icu_provider_adapters::filter::FilterDataProvider", // Not planned for 2.0 // ForkByErrorProvider is the abstract forking provider; we expose the concrete