Debian Codegraph @

intl/icu_capi/src/lib.rs

raw
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(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/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 // Common modules
60
61 pub mod common;
62 pub mod data_struct;
63 pub mod errors;
64 pub mod locale;
65 #[cfg(feature = "logging")]
66 pub mod logging;
67 #[macro_use]
68 pub mod provider;
69 mod utf;
70
71 // Components
72
73 #[cfg(feature = "icu_properties")]
74 pub mod bidi;
75 #[cfg(any(
76 feature = "icu_datetime",
77 feature = "icu_timezone",
78 feature = "icu_calendar"
79 ))]
80 pub mod calendar;
81 #[cfg(feature = "icu_casemap")]
82 pub mod casemap;
83 #[cfg(feature = "icu_collator")]
84 pub mod collator;
85 #[cfg(feature = "icu_properties")]
86 pub mod collections_sets;
87 #[cfg(any(
88 feature = "icu_datetime",
89 feature = "icu_timezone",
90 feature = "icu_calendar"
91 ))]
92 pub mod date;
93 #[cfg(any(
94 feature = "icu_datetime",
95 feature = "icu_timezone",
96 feature = "icu_calendar"
97 ))]
98 pub mod datetime;
99 #[cfg(feature = "icu_datetime")]
100 pub mod datetime_formatter;
101 #[cfg(feature = "icu_decimal")]
102 pub mod decimal;
103 #[cfg(feature = "experimental_components")]
104 pub mod displaynames;
105 #[cfg(feature = "icu_locid_transform")]
106 pub mod fallbacker;
107 #[cfg(feature = "icu_decimal")]
108 pub mod fixed_decimal;
109 #[cfg(any(feature = "icu_datetime", feature = "icu_timezone"))]
110 pub mod iana_bcp47_mapper;
111 #[cfg(feature = "icu_list")]
112 pub mod list;
113 #[cfg(feature = "icu_locid_transform")]
114 pub mod locale_directionality;
115 #[cfg(feature = "icu_locid_transform")]
116 pub mod locid_transform;
117 #[cfg(feature = "icu_timezone")]
118 pub mod metazone_calculator;
119 #[cfg(feature = "icu_normalizer")]
120 pub mod normalizer;
121 #[cfg(feature = "icu_normalizer")]
122 pub mod normalizer_properties;
123 #[cfg(feature = "icu_plurals")]
124 pub mod pluralrules;
125 #[cfg(feature = "icu_properties")]
126 pub mod properties_iter;
127 #[cfg(feature = "icu_properties")]
128 pub mod properties_maps;
129 #[cfg(feature = "icu_properties")]
130 pub mod properties_names;
131 #[cfg(feature = "icu_properties")]
132 pub mod properties_sets;
133 #[cfg(feature = "icu_properties")]
134 pub mod properties_unisets;
135 #[cfg(feature = "icu_properties")]
136 pub mod script;
137 #[cfg(feature = "icu_segmenter")]
138 pub mod segmenter_grapheme;
139 #[cfg(feature = "icu_segmenter")]
140 pub mod segmenter_line;
141 #[cfg(feature = "icu_segmenter")]
142 pub mod segmenter_sentence;
143 #[cfg(feature = "icu_segmenter")]
144 pub mod segmenter_word;
145 #[cfg(any(
146 feature = "icu_datetime",
147 feature = "icu_timezone",
148 feature = "icu_calendar"
149 ))]
150 pub mod time;
151 #[cfg(any(feature = "icu_datetime", feature = "icu_timezone"))]
152 pub mod timezone;
153 #[cfg(feature = "icu_datetime")]
154 pub mod timezone_formatter;
155 #[cfg(any(feature = "icu_datetime", feature = "icu_timezone"))]
156 pub mod timezone_mapper;
157 #[cfg(feature = "experimental_components")]
158 pub mod units_converter;
159 #[cfg(feature = "icu_calendar")]
160 pub mod week;
161 #[cfg(feature = "icu_datetime")]
162 pub mod zoned_formatter;