icu_provider_adapters/
empty.rs1use alloc::collections::BTreeSet;
10#[cfg(feature = "export")]
11use icu_provider::export::ExportableProvider;
12use icu_provider::prelude::*;
13
14#[derive(Debug)]
36pub struct EmptyDataProvider {
37 error_kind: DataErrorKind,
38}
39
40impl Default for EmptyDataProvider {
41 fn default() -> Self {
42 Self::new()
43 }
44}
45
46impl EmptyDataProvider {
47 pub fn new() -> Self {
49 Self {
50 error_kind: DataErrorKind::MarkerNotFound,
51 }
52 }
53
54 pub fn new_with_error_kind(error_kind: DataErrorKind) -> Self {
56 Self { error_kind }
57 }
58}
59
60impl<M> DynamicDataProvider<M> for EmptyDataProvider
61where
62 M: DynamicDataMarker,
63{
64 fn load_data(
65 &self,
66 marker: DataMarkerInfo,
67 base_req: DataRequest,
68 ) -> Result<DataResponse<M>, DataError> {
69 Err(self.error_kind.with_req(marker, base_req))
70 }
71}
72
73impl<M> DataProvider<M> for EmptyDataProvider
74where
75 M: DataMarker,
76{
77 fn load(&self, base_req: DataRequest) -> Result<DataResponse<M>, DataError> {
78 Err(self.error_kind.with_req(M::INFO, base_req))
79 }
80}
81
82impl<M> IterableDataProvider<M> for EmptyDataProvider
83where
84 M: DataMarker,
85{
86 fn iter_ids(&self) -> Result<BTreeSet<DataIdentifierCow<'_>>, DataError> {
87 Ok(Default::default())
88 }
89}
90
91impl<M> IterableDynamicDataProvider<M> for EmptyDataProvider
92where
93 M: DynamicDataMarker,
94{
95 fn iter_ids_for_marker(
96 &self,
97 _: DataMarkerInfo,
98 ) -> Result<BTreeSet<DataIdentifierCow<'_>>, DataError> {
99 Ok(Default::default())
100 }
101}
102
103#[cfg(feature = "export")]
104impl ExportableProvider for EmptyDataProvider {
105 fn supported_markers(&self) -> alloc::collections::BTreeSet<DataMarkerInfo> {
106 Default::default()
107 }
108}