icu_capi/
lib.rs

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