lib.rs (6150B)
1 // This file is part of ICU4X. For terms of use, please see the file 2 // called LICENSE at the top level of the ICU4X source tree 3 // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). 4 5 // https://github.com/unicode-org/icu4x/blob/main/documents/process/boilerplate.md#library-annotations 6 #![cfg_attr(not(any(test, feature = "std")), no_std)] 7 #![cfg_attr( 8 not(test), 9 deny( 10 clippy::indexing_slicing, 11 clippy::unwrap_used, 12 clippy::expect_used, 13 clippy::panic, 14 // Exhaustiveness and Debug is not required for Diplomat types 15 ) 16 )] 17 // Diplomat limitations 18 #![allow( 19 clippy::needless_lifetimes, 20 clippy::result_unit_err, 21 clippy::should_implement_trait 22 )] 23 24 //! This crate contains the source of truth for the [Diplomat](https://github.com/rust-diplomat/diplomat)-generated 25 //! FFI bindings. This generates the C, C++, JavaScript, and TypeScript bindings. This crate also contains the `extern "C"` 26 //! FFI for ICU4X. 27 //! 28 //! While the types in this crate are public, APIs from this crate are *not intended to be used from Rust* 29 //! and as such this crate may unpredictably change its Rust API across compatible semver versions. The `extern "C"` APIs exposed 30 //! by this crate, while not directly documented, are stable within the same major semver version, as are the bindings exposed under 31 //! the `cpp/` and `js/` folders. 32 //! 33 //! This crate may still be explored for documentation on docs.rs, and there are language-specific docs available as well. 34 //! C++, Dart, and TypeScript headers contain inline documentation, which is available pre-rendered: [C++], [TypeScript]. 35 //! 36 //! This crate is `no_std`-compatible. If you wish to use it in `no_std` mode, you must write a wrapper crate that defines an allocator 37 //! and a panic hook in order to compile as a C library. 38 //! 39 //! More information on using ICU4X from C++ can be found in [our tutorial]. 40 //! 41 //! [our tutorial]: https://github.com/unicode-org/icu4x/blob/main/tutorials/using-from-cpp.md 42 //! [TypeScript]: https://unicode-org.github.io/icu4x/tsdoc 43 //! [C++]: https://unicode-org.github.io/icu4x/cppdoc 44 45 // Renamed so you can't accidentally use it 46 #[cfg(target_arch = "wasm32")] 47 extern crate std as rust_std; 48 49 #[cfg(all(not(feature = "std"), feature = "looping_panic_handler"))] 50 #[panic_handler] 51 fn panic(_info: &core::panic::PanicInfo) -> ! { 52 loop {} 53 } 54 55 extern crate alloc; 56 #[cfg(all(not(feature = "std"), feature = "libc_alloc"))] 57 extern crate libc_alloc; 58 59 #[cfg(feature = "datetime")] 60 pub(crate) mod datetime_helpers; 61 62 /// The Rust API of this crate is **UNSTABLE**; this crate is primarily intended 63 /// to be used from its FFI bindings, packaged with the crate. 64 /// 65 /// The C ABI layer is stable. 66 #[path = "."] // https://github.com/rust-lang/rust/issues/35016 67 pub mod unstable { 68 // Common modules 69 pub mod errors; 70 pub mod locale_core; 71 #[cfg(feature = "logging")] 72 pub mod logging; 73 #[macro_use] 74 pub mod provider; 75 76 // Components 77 78 #[cfg(feature = "properties")] 79 pub mod bidi; 80 #[cfg(any(feature = "datetime", feature = "timezone", feature = "calendar"))] 81 pub mod calendar; 82 #[cfg(feature = "casemap")] 83 pub mod casemap; 84 #[cfg(feature = "collator")] 85 pub mod collator; 86 #[cfg(feature = "properties")] 87 pub mod collections_sets; 88 #[cfg(any(feature = "datetime", feature = "timezone", feature = "calendar"))] 89 pub mod date; 90 #[cfg(feature = "datetime")] 91 pub mod date_formatter; 92 #[cfg(feature = "datetime")] 93 pub mod date_time_formatter; 94 #[cfg(any(feature = "datetime", feature = "timezone", feature = "calendar"))] 95 pub mod datetime; 96 #[cfg(feature = "datetime")] 97 pub mod datetime_options; 98 #[cfg(feature = "decimal")] 99 pub mod decimal; 100 #[cfg(feature = "experimental")] 101 pub mod displaynames; 102 #[cfg(feature = "locale")] 103 pub mod exemplar_chars; 104 #[cfg(feature = "locale")] 105 pub mod fallbacker; 106 #[cfg(feature = "decimal")] 107 pub mod fixed_decimal; 108 #[cfg(any(feature = "datetime", feature = "timezone"))] 109 pub mod iana_parser; 110 #[cfg(feature = "list")] 111 pub mod list; 112 #[cfg(feature = "locale")] 113 pub mod locale; 114 #[cfg(feature = "locale")] 115 pub mod locale_directionality; 116 #[cfg(feature = "experimental")] 117 pub mod measure_unit_parser; 118 #[cfg(feature = "normalizer")] 119 pub mod normalizer; 120 #[cfg(feature = "normalizer")] 121 pub mod normalizer_properties; 122 #[cfg(feature = "plurals")] 123 pub mod pluralrules; 124 #[cfg(feature = "properties")] 125 pub mod properties_bidi; 126 #[cfg(feature = "properties")] 127 pub mod properties_enums; 128 #[cfg(feature = "properties")] 129 pub mod properties_iter; 130 #[cfg(feature = "properties")] 131 pub mod properties_maps; 132 #[cfg(feature = "properties")] 133 pub mod properties_names; 134 #[cfg(feature = "properties")] 135 pub mod properties_sets; 136 #[cfg(feature = "properties")] 137 pub mod properties_unisets; 138 #[cfg(feature = "properties")] 139 pub mod script; 140 #[cfg(feature = "segmenter")] 141 pub mod segmenter_grapheme; 142 #[cfg(feature = "segmenter")] 143 pub mod segmenter_line; 144 #[cfg(feature = "segmenter")] 145 pub mod segmenter_sentence; 146 #[cfg(feature = "segmenter")] 147 pub mod segmenter_word; 148 #[cfg(any(feature = "datetime", feature = "timezone", feature = "calendar"))] 149 pub mod time; 150 #[cfg(feature = "datetime")] 151 pub mod time_formatter; 152 #[cfg(any(feature = "datetime", feature = "timezone"))] 153 pub mod timezone; 154 #[cfg(feature = "datetime")] 155 pub mod timezone_formatter; 156 #[cfg(feature = "experimental")] 157 pub mod units_converter; 158 #[cfg(any(feature = "datetime", feature = "timezone"))] 159 pub mod variant_offset; 160 #[cfg(feature = "calendar")] 161 pub mod week; 162 #[cfg(any(feature = "datetime", feature = "timezone"))] 163 pub mod windows_parser; 164 #[cfg(feature = "datetime")] 165 pub mod zoned_date_formatter; 166 #[cfg(feature = "datetime")] 167 pub mod zoned_date_time_formatter; 168 #[cfg(feature = "datetime")] 169 pub mod zoned_datetime; 170 #[cfg(feature = "datetime")] 171 pub mod zoned_time_formatter; 172 }