1#[doc(hidden)]
115#[macro_export]
116macro_rules! gen_any_buffer_unstable_docs {
117 (ANY, $data:path) => {
118 concat!(
119 "A version of [`", stringify!($data), "`] that uses custom data ",
120 "provided by an [`AnyProvider`](icu_provider::AnyProvider).\n\n",
121 "[📚 Help choosing a constructor](icu_provider::constructors)",
122 )
123 };
124 (BUFFER, $data:path) => {
125 concat!(
126 "A version of [`", stringify!($data), "`] that uses custom data ",
127 "provided by a [`BufferProvider`](icu_provider::BufferProvider).\n\n",
128 "✨ *Enabled with the `serde` feature.*\n\n",
129 "[📚 Help choosing a constructor](icu_provider::constructors)",
130 )
131 };
132 (UNSTABLE, $data:path) => {
133 concat!(
134 "A version of [`", stringify!($data), "`] that uses custom data ",
135 "provided by a [`DataProvider`](icu_provider::DataProvider).\n\n",
136 "[📚 Help choosing a constructor](icu_provider::constructors)\n\n",
137 "<div class=\"stab unstable\">⚠️ The bounds on <tt>provider</tt> may change over time, including in SemVer minor releases.</div>"
138 )
139 };
140}
141
142#[allow(clippy::crate_in_macro_def)] #[doc(hidden)]
144#[macro_export]
145macro_rules! gen_any_buffer_data_constructors {
146 (locale: skip, options: skip, error: $error_ty:path, $(#[$doc:meta])+) => {
147 $crate::gen_any_buffer_data_constructors!(
148 locale: skip,
149 options: skip,
150 error: $error_ty,
151 $(#[$doc])+
152 functions: [
153 try_new,
154 try_new_with_any_provider,
155 try_new_with_buffer_provider,
156 try_new_unstable,
157 Self,
158 ]
159 );
160 };
161 (locale: skip, options: skip, error: $error_ty:path, $(#[$doc:meta])+ functions: [$baked:ident, $any:ident, $buffer:ident, $unstable:ident $(, $struct:ident)? $(,)?]) => {
162 #[cfg(feature = "compiled_data")]
163 $(#[$doc])+
164 pub fn $baked() -> Result<Self, $error_ty> {
165 $($struct :: )? $unstable(&crate::provider::Baked)
166 }
167 #[doc = $crate::gen_any_buffer_unstable_docs!(ANY, $($struct ::)? $baked)]
168 pub fn $any(provider: &(impl $crate::AnyProvider + ?Sized)) -> Result<Self, $error_ty> {
169 use $crate::AsDowncastingAnyProvider;
170 $($struct :: )? $unstable(&provider.as_downcasting())
171 }
172 #[cfg(feature = "serde")]
173 #[doc = $crate::gen_any_buffer_unstable_docs!(BUFFER, $($struct ::)? $baked)]
174 pub fn $buffer(provider: &(impl $crate::BufferProvider + ?Sized)) -> Result<Self, $error_ty> {
175 use $crate::AsDeserializingBufferProvider;
176 $($struct :: )? $unstable(&provider.as_deserializing())
177 }
178 };
179
180
181 (locale: skip, options: skip, result: $result_ty:path, $(#[$doc:meta])+ functions: [$baked:ident, $any:ident, $buffer:ident, $unstable:ident $(, $struct:ident)? $(,)?]) => {
182 #[cfg(feature = "compiled_data")]
183 $(#[$doc])+
184 pub fn $baked() -> $result_ty {
185 $($struct :: )? $unstable(&crate::provider::Baked)
186 }
187 #[doc = $crate::gen_any_buffer_unstable_docs!(ANY, $($struct ::)? $baked)]
188 pub fn $any(provider: &(impl $crate::AnyProvider + ?Sized)) -> $result_ty {
189 use $crate::AsDowncastingAnyProvider;
190 $($struct :: )? $unstable(&provider.as_downcasting())
191 }
192 #[cfg(feature = "serde")]
193 #[doc = $crate::gen_any_buffer_unstable_docs!(BUFFER, $($struct ::)? $baked)]
194 pub fn $buffer(provider: &(impl $crate::BufferProvider + ?Sized)) -> $result_ty {
195 use $crate::AsDeserializingBufferProvider;
196 $($struct :: )? $unstable(&provider.as_deserializing())
197 }
198 };
199
200 (locale: skip, $options_arg:ident: $options_ty:ty, error: $error_ty:path, $(#[$doc:meta])+) => {
201 $crate::gen_any_buffer_data_constructors!(
202 locale: skip,
203 $options_arg: $options_ty,
204 error: $error_ty,
205 $(#[$doc])+
206 functions: [
207 try_new,
208 try_new_with_any_provider,
209 try_new_with_buffer_provider,
210 try_new_unstable,
211 Self,
212 ]
213 );
214 };
215 (locale: skip, $options_arg:ident: $options_ty:ty, result: $result_ty:ty, $(#[$doc:meta])+ functions: [$baked:ident, $any:ident, $buffer:ident, $unstable:ident $(, $struct:ident)? $(,)?]) => {
216 #[cfg(feature = "compiled_data")]
217 $(#[$doc])+
218 pub fn $baked($options_arg: $options_ty) -> $result_ty {
223 $($struct :: )? $unstable(&crate::provider::Baked, $options_arg)
224 }
225 #[doc = $crate::gen_any_buffer_unstable_docs!(ANY, $($struct ::)? $baked)]
226 pub fn $any(provider: &(impl $crate::AnyProvider + ?Sized), $options_arg: $options_ty) -> $result_ty {
227 use $crate::AsDowncastingAnyProvider;
228 $($struct :: )? $unstable(&provider.as_downcasting(), $options_arg)
229 }
230 #[cfg(feature = "serde")]
231 #[doc = $crate::gen_any_buffer_unstable_docs!(BUFFER, $($struct ::)? $baked)]
232 pub fn $buffer(provider: &(impl $crate::BufferProvider + ?Sized), $options_arg: $options_ty) -> $result_ty {
233 use $crate::AsDeserializingBufferProvider;
234 $($struct :: )? $unstable(&provider.as_deserializing(), $options_arg)
235 }
236 };
237 (locale: skip, $options_arg:ident: $options_ty:ty, error: $error_ty:ty, $(#[$doc:meta])+ functions: [$baked:ident, $any:ident, $buffer:ident, $unstable:ident $(, $struct:ident)? $(,)?]) => {
238 #[cfg(feature = "compiled_data")]
239 $(#[$doc])+
240 pub fn $baked($options_arg: $options_ty) -> Result<Self, $error_ty> {
245 $($struct :: )? $unstable(&crate::provider::Baked, $options_arg)
246 }
247 #[doc = $crate::gen_any_buffer_unstable_docs!(ANY, $($struct ::)? $baked)]
248 pub fn $any(provider: &(impl $crate::AnyProvider + ?Sized), $options_arg: $options_ty) -> Result<Self, $error_ty> {
249 use $crate::AsDowncastingAnyProvider;
250 $($struct :: )? $unstable(&provider.as_downcasting(), $options_arg)
251 }
252 #[cfg(feature = "serde")]
253 #[doc = $crate::gen_any_buffer_unstable_docs!(BUFFER, $($struct ::)? $baked)]
254 pub fn $buffer(provider: &(impl $crate::BufferProvider + ?Sized), $options_arg: $options_ty) -> Result<Self, $error_ty> {
255 use $crate::AsDeserializingBufferProvider;
256 $($struct :: )? $unstable(&provider.as_deserializing(), $options_arg)
257 }
258 };
259 (locale: include, options: skip, error: $error_ty:path, $(#[$doc:meta])+) => {
260 $crate::gen_any_buffer_data_constructors!(
261 locale: include,
262 options: skip,
263 error: $error_ty,
264 $(#[$doc])+
265 functions: [
266 try_new,
267 try_new_with_any_provider,
268 try_new_with_buffer_provider,
269 try_new_unstable,
270 Self,
271 ]
272 );
273 };
274 (locale: include, options: skip, error: $error_ty:path, $(#[$doc:meta])+ functions: [$baked:ident, $any:ident, $buffer:ident, $unstable:ident $(, $struct:ident)? $(,)?]) => {
275 #[cfg(feature = "compiled_data")]
276 $(#[$doc])+
277 pub fn $baked(locale: &$crate::DataLocale) -> Result<Self, $error_ty> {
282 $($struct :: )? $unstable(&crate::provider::Baked, locale)
283 }
284 #[doc = $crate::gen_any_buffer_unstable_docs!(ANY, $($struct ::)? $baked)]
285 pub fn $any(provider: &(impl $crate::AnyProvider + ?Sized), locale: &$crate::DataLocale) -> Result<Self, $error_ty> {
286 use $crate::AsDowncastingAnyProvider;
287 $($struct :: )? $unstable(&provider.as_downcasting(), locale)
288 }
289 #[cfg(feature = "serde")]
290 #[doc = $crate::gen_any_buffer_unstable_docs!(BUFFER, $($struct ::)? $baked)]
291 pub fn $buffer(provider: &(impl $crate::BufferProvider + ?Sized), locale: &$crate::DataLocale) -> Result<Self, $error_ty> {
292 use $crate::AsDeserializingBufferProvider;
293 $($struct :: )? $unstable(&provider.as_deserializing(), locale)
294 }
295 };
296
297 (locale: include, $config_arg:ident: $config_ty:path, $options_arg:ident: $options_ty:path, error: $error_ty:path, $(#[$doc:meta])+) => {
298 $crate::gen_any_buffer_data_constructors!(
299 locale: include,
300 $config_arg: $config_ty,
301 $options_arg: $options_ty,
302 error: $error_ty,
303 $(#[$doc])+
304 functions: [
305 try_new,
306 try_new_with_any_provider,
307 try_new_with_buffer_provider,
308 try_new_unstable,
309 Self,
310 ]
311 );
312 };
313 (locale: include, $config_arg:ident: $config_ty:path, $options_arg:ident: $options_ty:path, error: $error_ty:path, $(#[$doc:meta])+ functions: [$baked:ident, $any:ident, $buffer:ident, $unstable:ident $(, $struct:ident)? $(,)?]) => {
314 #[cfg(feature = "compiled_data")]
315 $(#[$doc])+
316 pub fn $baked(locale: &$crate::DataLocale, $config_arg: $config_ty, $options_arg: $options_ty) -> Result<Self, $error_ty> {
321 $($struct :: )? $unstable(&crate::provider::Baked, locale, $config_arg, $options_arg)
322 }
323 #[doc = $crate::gen_any_buffer_unstable_docs!(ANY, $($struct ::)? $baked)]
324 pub fn $any(provider: &(impl $crate::AnyProvider + ?Sized), locale: &$crate::DataLocale, $config_arg: $config_ty, $options_arg: $options_ty) -> Result<Self, $error_ty> {
325 use $crate::AsDowncastingAnyProvider;
326 $($struct :: )? $unstable(&provider.as_downcasting(), locale, $config_arg, $options_arg)
327 }
328 #[cfg(feature = "serde")]
329 #[doc = $crate::gen_any_buffer_unstable_docs!(BUFFER, $($struct ::)? $baked)]
330 pub fn $buffer(provider: &(impl $crate::BufferProvider + ?Sized), locale: &$crate::DataLocale, $config_arg: $config_ty, $options_arg: $options_ty) -> Result<Self, $error_ty> {
331 use $crate::AsDeserializingBufferProvider;
332 $($struct :: )? $unstable(&provider.as_deserializing(), locale, $config_arg, $options_arg)
333 }
334 };
335
336 (locale: include, $options_arg:ident: $options_ty:path, error: $error_ty:path, $(#[$doc:meta])+) => {
337 $crate::gen_any_buffer_data_constructors!(
338 locale: include,
339 $options_arg: $options_ty,
340 error: $error_ty,
341 $(#[$doc])+
342 functions: [
343 try_new,
344 try_new_with_any_provider,
345 try_new_with_buffer_provider,
346 try_new_unstable,
347 Self,
348 ]
349 );
350 };
351 (locale: include, $options_arg:ident: $options_ty:path, error: $error_ty:path, $(#[$doc:meta])+ functions: [$baked:ident, $any:ident, $buffer:ident, $unstable:ident $(, $struct:ident)? $(,)?]) => {
352 #[cfg(feature = "compiled_data")]
353 $(#[$doc])+
354 pub fn $baked(locale: &$crate::DataLocale, $options_arg: $options_ty) -> Result<Self, $error_ty> {
359 $($struct :: )? $unstable(&crate::provider::Baked, locale, $options_arg)
360 }
361 #[doc = $crate::gen_any_buffer_unstable_docs!(ANY, $($struct ::)? $baked)]
362 pub fn $any(provider: &(impl $crate::AnyProvider + ?Sized), locale: &$crate::DataLocale, $options_arg: $options_ty) -> Result<Self, $error_ty> {
363 use $crate::AsDowncastingAnyProvider;
364 $($struct :: )? $unstable(&provider.as_downcasting(), locale, $options_arg)
365 }
366 #[cfg(feature = "serde")]
367 #[doc = $crate::gen_any_buffer_unstable_docs!(BUFFER, $($struct ::)? $baked)]
368 pub fn $buffer(provider: &(impl $crate::BufferProvider + ?Sized), locale: &$crate::DataLocale, $options_arg: $options_ty) -> Result<Self, $error_ty> {
369 use $crate::AsDeserializingBufferProvider;
370 $($struct :: )? $unstable(&provider.as_deserializing(), locale, $options_arg)
371 }
372 };
373}