#[diplomat::bridge]
#[diplomat::abi_rename = "icu4x_{0}_mv1"]
#[diplomat::attr(auto, namespace = "icu4x")]
pub mod ffi {
use alloc::boxed::Box;
#[cfg(feature = "buffer_provider")]
use crate::{errors::ffi::DataError, provider::ffi::DataProvider};
#[diplomat::opaque]
#[diplomat::rust_link(icu::normalizer::ComposingNormalizer, Struct)]
#[diplomat::rust_link(icu::normalizer::ComposingNormalizerBorrowed, Struct, hidden)]
pub struct ComposingNormalizer(pub icu_normalizer::ComposingNormalizer);
impl ComposingNormalizer {
#[diplomat::rust_link(icu::normalizer::ComposingNormalizer::new_nfc, FnInStruct)]
#[diplomat::rust_link(
icu::normalizer::ComposingNormalizerBorrowed::new_nfc,
FnInStruct,
hidden
)]
#[diplomat::attr(auto, named_constructor = "nfc")]
#[diplomat::demo(default_constructor)]
#[cfg(feature = "compiled_data")]
pub fn create_nfc() -> Box<ComposingNormalizer> {
Box::new(ComposingNormalizer(
icu_normalizer::ComposingNormalizer::new_nfc().static_to_owned(),
))
}
#[diplomat::rust_link(icu::normalizer::ComposingNormalizer::new_nfc, FnInStruct)]
#[diplomat::rust_link(
icu::normalizer::ComposingNormalizerBorrowed::new_nfc,
FnInStruct,
hidden
)]
#[diplomat::attr(supports = fallible_constructors, named_constructor = "nfc_with_provider")]
#[cfg(feature = "buffer_provider")]
pub fn create_nfc_with_provider(
provider: &DataProvider,
) -> Result<Box<ComposingNormalizer>, DataError> {
Ok(Box::new(ComposingNormalizer(provider.call_constructor(
|provider| {
icu_normalizer::ComposingNormalizer::try_new_nfc_with_buffer_provider(provider)
},
)?)))
}
#[diplomat::rust_link(icu::normalizer::ComposingNormalizer::new_nfkc, FnInStruct)]
#[diplomat::rust_link(
icu::normalizer::ComposingNormalizerBorrowed::new_nfkc,
FnInStruct,
hidden
)]
#[diplomat::attr(auto, named_constructor = "nfkc")]
#[cfg(feature = "compiled_data")]
pub fn create_nfkc() -> Box<ComposingNormalizer> {
Box::new(ComposingNormalizer(
icu_normalizer::ComposingNormalizer::new_nfkc().static_to_owned(),
))
}
#[diplomat::rust_link(icu::normalizer::ComposingNormalizer::new_nfkc, FnInStruct)]
#[diplomat::rust_link(
icu::normalizer::ComposingNormalizerBorrowed::new_nfkc,
FnInStruct,
hidden
)]
#[diplomat::attr(supports = fallible_constructors, named_constructor = "nfkc_with_provider")]
#[cfg(feature = "buffer_provider")]
pub fn create_nfkc_with_provider(
provider: &DataProvider,
) -> Result<Box<ComposingNormalizer>, DataError> {
Ok(Box::new(ComposingNormalizer(provider.call_constructor(
|provider| {
icu_normalizer::ComposingNormalizer::try_new_nfkc_with_buffer_provider(provider)
},
)?)))
}
#[diplomat::rust_link(
icu::normalizer::ComposingNormalizerBorrowed::normalize_utf8,
FnInStruct
)]
#[diplomat::rust_link(
icu::normalizer::ComposingNormalizerBorrowed::normalize,
FnInStruct,
hidden
)]
#[diplomat::rust_link(
icu::normalizer::ComposingNormalizerBorrowed::normalize_to,
FnInStruct,
hidden
)]
#[diplomat::rust_link(
icu::normalizer::ComposingNormalizerBorrowed::normalize_utf8_to,
FnInStruct,
hidden
)]
pub fn normalize(&self, s: &DiplomatStr, write: &mut DiplomatWrite) {
let _infallible = self.0.as_borrowed().normalize_utf8_to(s, write);
}
#[diplomat::rust_link(
icu::normalizer::ComposingNormalizerBorrowed::is_normalized_utf8,
FnInStruct
)]
#[diplomat::rust_link(
icu::normalizer::ComposingNormalizerBorrowed::is_normalized,
FnInStruct,
hidden
)]
#[diplomat::attr(not(supports = utf8_strings), disable)]
#[diplomat::attr(*, rename = "is_normalized")]
pub fn is_normalized_utf8(&self, s: &DiplomatStr) -> bool {
self.0.as_borrowed().is_normalized_utf8(s)
}
#[diplomat::rust_link(
icu::normalizer::ComposingNormalizerBorrowed::is_normalized_utf16,
FnInStruct
)]
#[diplomat::attr(not(supports = utf8_strings), rename = "is_normalized")]
#[diplomat::attr(supports = utf8_strings, rename = "is_normalized16")]
pub fn is_normalized_utf16(&self, s: &DiplomatStr16) -> bool {
self.0.as_borrowed().is_normalized_utf16(s)
}
#[diplomat::rust_link(
icu::normalizer::ComposingNormalizerBorrowed::is_normalized_utf8_up_to,
FnInStruct
)]
#[diplomat::rust_link(
icu::normalizer::ComposingNormalizerBorrowed::is_normalized_up_to,
FnInStruct,
hidden
)]
#[diplomat::attr(not(supports = utf8_strings), disable)]
#[diplomat::attr(*, rename = "is_normalized_up_to")]
pub fn is_normalized_utf8_up_to(&self, s: &DiplomatStr) -> usize {
self.0.as_borrowed().is_normalized_utf8_up_to(s)
}
#[diplomat::rust_link(
icu::normalizer::ComposingNormalizerBorrowed::is_normalized_utf16_up_to,
FnInStruct
)]
#[diplomat::attr(not(supports = utf8_strings), rename = "is_normalized_up_to")]
#[diplomat::attr(supports = utf8_strings, rename = "is_normalized16_up_to")]
pub fn is_normalized_utf16_up_to(&self, s: &DiplomatStr16) -> usize {
self.0.as_borrowed().is_normalized_utf16_up_to(s)
}
}
#[diplomat::opaque]
#[diplomat::rust_link(icu::normalizer::DecomposingNormalizer, Struct)]
#[diplomat::rust_link(icu::normalizer::DecomposingNormalizerBorrowed, Struct, hidden)]
pub struct DecomposingNormalizer(pub icu_normalizer::DecomposingNormalizer);
impl DecomposingNormalizer {
#[diplomat::rust_link(icu::normalizer::DecomposingNormalizer::new_nfd, FnInStruct)]
#[diplomat::rust_link(
icu::normalizer::DecomposingNormalizerBorrowed::new_nfd,
FnInStruct,
hidden
)]
#[diplomat::attr(supports = fallible_constructors, named_constructor = "nfd")]
#[diplomat::demo(default_constructor)]
#[cfg(feature = "compiled_data")]
pub fn create_nfd() -> Box<DecomposingNormalizer> {
Box::new(DecomposingNormalizer(
icu_normalizer::DecomposingNormalizer::new_nfd().static_to_owned(),
))
}
#[diplomat::rust_link(icu::normalizer::DecomposingNormalizer::new_nfd, FnInStruct)]
#[diplomat::rust_link(
icu::normalizer::DecomposingNormalizerBorrowed::new_nfd,
FnInStruct,
hidden
)]
#[diplomat::attr(supports = fallible_constructors, named_constructor = "nfd_with_provider")]
#[cfg(feature = "buffer_provider")]
pub fn create_nfd_with_provider(
provider: &DataProvider,
) -> Result<Box<DecomposingNormalizer>, DataError> {
Ok(Box::new(DecomposingNormalizer(provider.call_constructor(
|provider| {
icu_normalizer::DecomposingNormalizer::try_new_nfd_with_buffer_provider(
provider,
)
},
)?)))
}
#[diplomat::rust_link(icu::normalizer::DecomposingNormalizer::new_nfkd, FnInStruct)]
#[diplomat::rust_link(
icu::normalizer::DecomposingNormalizerBorrowed::new_nfkd,
FnInStruct,
hidden
)]
#[diplomat::attr(auto, named_constructor = "nfkd")]
#[cfg(feature = "compiled_data")]
pub fn create_nfkd() -> Box<DecomposingNormalizer> {
Box::new(DecomposingNormalizer(
icu_normalizer::DecomposingNormalizer::new_nfkd().static_to_owned(),
))
}
#[diplomat::rust_link(icu::normalizer::DecomposingNormalizer::new_nfkd, FnInStruct)]
#[diplomat::rust_link(
icu::normalizer::DecomposingNormalizerBorrowed::new_nfkd,
FnInStruct,
hidden
)]
#[diplomat::attr(supports = fallible_constructors, named_constructor = "nfkd_with_provider")]
#[cfg(feature = "buffer_provider")]
pub fn create_nfkd_with_provider(
provider: &DataProvider,
) -> Result<Box<DecomposingNormalizer>, DataError> {
Ok(Box::new(DecomposingNormalizer(provider.call_constructor(
|provider| {
icu_normalizer::DecomposingNormalizer::try_new_nfkd_with_buffer_provider(
provider,
)
},
)?)))
}
#[diplomat::rust_link(
icu::normalizer::DecomposingNormalizerBorrowed::normalize_utf8,
FnInStruct
)]
#[diplomat::rust_link(
icu::normalizer::DecomposingNormalizerBorrowed::normalize,
FnInStruct,
hidden
)]
#[diplomat::rust_link(
icu::normalizer::DecomposingNormalizerBorrowed::normalize_to,
FnInStruct,
hidden
)]
#[diplomat::rust_link(
icu::normalizer::DecomposingNormalizerBorrowed::normalize_utf8_to,
FnInStruct,
hidden
)]
pub fn normalize(&self, s: &DiplomatStr, write: &mut DiplomatWrite) {
let _infallible = self.0.as_borrowed().normalize_utf8_to(s, write);
}
#[diplomat::rust_link(
icu::normalizer::DecomposingNormalizerBorrowed::is_normalized_utf8,
FnInStruct
)]
#[diplomat::rust_link(
icu::normalizer::DecomposingNormalizerBorrowed::is_normalized,
FnInStruct,
hidden
)]
pub fn is_normalized(&self, s: &DiplomatStr) -> bool {
self.0.as_borrowed().is_normalized_utf8(s)
}
#[diplomat::rust_link(
icu::normalizer::DecomposingNormalizerBorrowed::is_normalized_utf16,
FnInStruct
)]
pub fn is_normalized_utf16(&self, s: &DiplomatStr16) -> bool {
self.0.as_borrowed().is_normalized_utf16(s)
}
#[diplomat::rust_link(
icu::normalizer::DecomposingNormalizerBorrowed::is_normalized_utf8_up_to,
FnInStruct
)]
#[diplomat::rust_link(
icu::normalizer::DecomposingNormalizerBorrowed::is_normalized_up_to,
FnInStruct,
hidden
)]
pub fn is_normalized_up_to(&self, s: &DiplomatStr) -> usize {
self.0.as_borrowed().is_normalized_utf8_up_to(s)
}
#[diplomat::rust_link(
icu::normalizer::DecomposingNormalizerBorrowed::is_normalized_utf16_up_to,
FnInStruct
)]
pub fn is_normalized_utf16_up_to(&self, s: &DiplomatStr16) -> usize {
self.0.as_borrowed().is_normalized_utf16_up_to(s)
}
}
}