objc2_foundation/generated/
NSLengthFormatter.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9#[repr(transparent)]
12#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
13pub struct NSLengthFormatterUnit(pub NSInteger);
14impl NSLengthFormatterUnit {
15 #[doc(alias = "NSLengthFormatterUnitMillimeter")]
16 pub const Millimeter: Self = Self(8);
17 #[doc(alias = "NSLengthFormatterUnitCentimeter")]
18 pub const Centimeter: Self = Self(9);
19 #[doc(alias = "NSLengthFormatterUnitMeter")]
20 pub const Meter: Self = Self(11);
21 #[doc(alias = "NSLengthFormatterUnitKilometer")]
22 pub const Kilometer: Self = Self(14);
23 #[doc(alias = "NSLengthFormatterUnitInch")]
24 pub const Inch: Self = Self((5 << 8) + 1);
25 #[doc(alias = "NSLengthFormatterUnitFoot")]
26 pub const Foot: Self = Self((5 << 8) + 2);
27 #[doc(alias = "NSLengthFormatterUnitYard")]
28 pub const Yard: Self = Self((5 << 8) + 3);
29 #[doc(alias = "NSLengthFormatterUnitMile")]
30 pub const Mile: Self = Self((5 << 8) + 4);
31}
32
33unsafe impl Encode for NSLengthFormatterUnit {
34 const ENCODING: Encoding = NSInteger::ENCODING;
35}
36
37unsafe impl RefEncode for NSLengthFormatterUnit {
38 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
39}
40
41extern_class!(
42 #[unsafe(super(NSFormatter, NSObject))]
44 #[derive(Debug, PartialEq, Eq, Hash)]
45 #[cfg(feature = "NSFormatter")]
46 pub struct NSLengthFormatter;
47);
48
49#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
50extern_conformance!(
51 unsafe impl NSCoding for NSLengthFormatter {}
52);
53
54#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
55extern_conformance!(
56 unsafe impl NSCopying for NSLengthFormatter {}
57);
58
59#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
60unsafe impl CopyingHelper for NSLengthFormatter {
61 type Result = Self;
62}
63
64#[cfg(feature = "NSFormatter")]
65extern_conformance!(
66 unsafe impl NSObjectProtocol for NSLengthFormatter {}
67);
68
69#[cfg(feature = "NSFormatter")]
70impl NSLengthFormatter {
71 extern_methods!(
72 #[cfg(feature = "NSNumberFormatter")]
73 #[unsafe(method(numberFormatter))]
74 #[unsafe(method_family = none)]
75 pub fn numberFormatter(&self) -> Retained<NSNumberFormatter>;
76
77 #[cfg(feature = "NSNumberFormatter")]
78 #[unsafe(method(setNumberFormatter:))]
82 #[unsafe(method_family = none)]
83 pub fn setNumberFormatter(&self, number_formatter: Option<&NSNumberFormatter>);
84
85 #[unsafe(method(unitStyle))]
86 #[unsafe(method_family = none)]
87 pub fn unitStyle(&self) -> NSFormattingUnitStyle;
88
89 #[unsafe(method(setUnitStyle:))]
91 #[unsafe(method_family = none)]
92 pub fn setUnitStyle(&self, unit_style: NSFormattingUnitStyle);
93
94 #[unsafe(method(isForPersonHeightUse))]
95 #[unsafe(method_family = none)]
96 pub fn isForPersonHeightUse(&self) -> bool;
97
98 #[unsafe(method(setForPersonHeightUse:))]
100 #[unsafe(method_family = none)]
101 pub fn setForPersonHeightUse(&self, for_person_height_use: bool);
102
103 #[cfg(feature = "NSString")]
104 #[unsafe(method(stringFromValue:unit:))]
105 #[unsafe(method_family = none)]
106 pub fn stringFromValue_unit(
107 &self,
108 value: c_double,
109 unit: NSLengthFormatterUnit,
110 ) -> Retained<NSString>;
111
112 #[cfg(feature = "NSString")]
113 #[unsafe(method(stringFromMeters:))]
114 #[unsafe(method_family = none)]
115 pub fn stringFromMeters(&self, number_in_meters: c_double) -> Retained<NSString>;
116
117 #[cfg(feature = "NSString")]
118 #[unsafe(method(unitStringFromValue:unit:))]
119 #[unsafe(method_family = none)]
120 pub fn unitStringFromValue_unit(
121 &self,
122 value: c_double,
123 unit: NSLengthFormatterUnit,
124 ) -> Retained<NSString>;
125
126 #[cfg(feature = "NSString")]
127 #[unsafe(method(unitStringFromMeters:usedUnit:))]
131 #[unsafe(method_family = none)]
132 pub unsafe fn unitStringFromMeters_usedUnit(
133 &self,
134 number_in_meters: c_double,
135 unitp: *mut NSLengthFormatterUnit,
136 ) -> Retained<NSString>;
137
138 #[cfg(feature = "NSString")]
139 #[unsafe(method(getObjectValue:forString:errorDescription:))]
143 #[unsafe(method_family = none)]
144 pub unsafe fn getObjectValue_forString_errorDescription(
145 &self,
146 obj: Option<&mut Option<Retained<AnyObject>>>,
147 string: &NSString,
148 error: Option<&mut Option<Retained<NSString>>>,
149 ) -> bool;
150 );
151}
152
153#[cfg(feature = "NSFormatter")]
155impl NSLengthFormatter {
156 extern_methods!(
157 #[unsafe(method(init))]
158 #[unsafe(method_family = init)]
159 pub fn init(this: Allocated<Self>) -> Retained<Self>;
160
161 #[unsafe(method(new))]
162 #[unsafe(method_family = new)]
163 pub fn new() -> Retained<Self>;
164 );
165}
166
167#[cfg(feature = "NSFormatter")]
168impl DefaultRetained for NSLengthFormatter {
169 #[inline]
170 fn default_retained() -> Retained<Self> {
171 Self::new()
172 }
173}