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 #[diplomat::bridge] 6 #[diplomat::abi_rename = "icu4x_{0}_mv1"] 7 #[diplomat::attr(auto, namespace = "icu4x")] 8 pub mod ffi { 9 use diplomat_runtime::DiplomatChar; 10 use icu_properties::props; 11 12 #[diplomat::rust_link(icu::properties::props::BidiMirroringGlyph, Struct)] 13 pub struct BidiMirroringGlyph { 14 /// The mirroring glyph 15 pub mirroring_glyph: DiplomatOption<DiplomatChar>, 16 /// Whether the glyph is mirrored 17 pub mirrored: bool, 18 /// The paired bracket type 19 pub paired_bracket_type: BidiPairedBracketType, 20 } 21 22 #[diplomat::rust_link(icu::properties::props::BidiPairedBracketType, Enum)] 23 #[diplomat::enum_convert(props::BidiPairedBracketType, needs_wildcard)] 24 pub enum BidiPairedBracketType { 25 /// Represents Bidi_Paired_Bracket_Type=Open. 26 Open, 27 /// Represents Bidi_Paired_Bracket_Type=Close. 28 Close, 29 /// Represents Bidi_Paired_Bracket_Type=None. 30 None, 31 } 32 33 impl BidiMirroringGlyph { 34 #[diplomat::rust_link(icu::properties::props::EnumeratedProperty::for_char, FnInTrait)] 35 #[cfg(feature = "compiled_data")] for_char(ch: DiplomatChar) -> Self36 pub fn for_char(ch: DiplomatChar) -> Self { 37 icu_properties::CodePointMapData::<props::BidiMirroringGlyph>::new() 38 .get32(ch) 39 .into() 40 } 41 } 42 } 43 44 impl From<icu_properties::props::BidiMirroringGlyph> for ffi::BidiMirroringGlyph { from(other: icu_properties::props::BidiMirroringGlyph) -> Self45 fn from(other: icu_properties::props::BidiMirroringGlyph) -> Self { 46 Self { 47 mirroring_glyph: other.mirroring_glyph.map(u32::from).into(), 48 mirrored: other.mirrored, 49 paired_bracket_type: other.paired_bracket_type.into(), 50 } 51 } 52 } 53