1 /*
2 * Copyright 2024 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 //! The rust component of libminikin
18
19 mod hyphenator;
20
21 pub use hyphenator::Hyphenator;
22
23 #[allow(clippy::needless_maybe_sized)]
24 #[cxx::bridge(namespace = "minikin::rust")]
25 mod ffi {
26 #[namespace = "minikin::rust"]
27 unsafe extern "C++" {
28 include!("ffi/IcuBridge.h");
getScript(cp: u32) -> u829 fn getScript(cp: u32) -> u8;
getJoiningType(cp: u32) -> u830 fn getJoiningType(cp: u32) -> u8;
31 }
32 #[namespace = "minikin::rust"]
33 extern "Rust" {
34 type Hyphenator;
load_hyphenator( data: &'static [u8], min_prefix: u32, min_suffix: u32, locale: String, ) -> Box<Hyphenator>35 fn load_hyphenator(
36 data: &'static [u8],
37 min_prefix: u32,
38 min_suffix: u32,
39 locale: String,
40 ) -> Box<Hyphenator>;
hyphenate(hyphenator: &Hyphenator, word: &[u16], out: &mut [u8])41 fn hyphenate(hyphenator: &Hyphenator, word: &[u16], out: &mut [u8]);
42 }
43 }
44
load_hyphenator( data: &'static [u8], min_prefix: u32, min_suffix: u32, locale: String, ) -> Box<Hyphenator>45 fn load_hyphenator(
46 data: &'static [u8],
47 min_prefix: u32,
48 min_suffix: u32,
49 locale: String,
50 ) -> Box<Hyphenator> {
51 Box::new(Hyphenator::new(data, min_prefix, min_suffix, &locale))
52 }
53
hyphenate(hyphenator: &Hyphenator, word: &[u16], out: &mut [u8])54 fn hyphenate(hyphenator: &Hyphenator, word: &[u16], out: &mut [u8]) {
55 hyphenator.hyphenate(word, out);
56 }
57