objc2_foundation/generated/
NSMassFormatter.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 NSMassFormatterUnit(pub NSInteger);
14impl NSMassFormatterUnit {
15 #[doc(alias = "NSMassFormatterUnitGram")]
16 pub const Gram: Self = Self(11);
17 #[doc(alias = "NSMassFormatterUnitKilogram")]
18 pub const Kilogram: Self = Self(14);
19 #[doc(alias = "NSMassFormatterUnitOunce")]
20 pub const Ounce: Self = Self((6 << 8) + 1);
21 #[doc(alias = "NSMassFormatterUnitPound")]
22 pub const Pound: Self = Self((6 << 8) + 2);
23 #[doc(alias = "NSMassFormatterUnitStone")]
24 pub const Stone: Self = Self((6 << 8) + 3);
25}
26
27unsafe impl Encode for NSMassFormatterUnit {
28 const ENCODING: Encoding = NSInteger::ENCODING;
29}
30
31unsafe impl RefEncode for NSMassFormatterUnit {
32 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
33}
34
35extern_class!(
36 #[unsafe(super(NSFormatter, NSObject))]
38 #[derive(Debug, PartialEq, Eq, Hash)]
39 #[cfg(feature = "NSFormatter")]
40 pub struct NSMassFormatter;
41);
42
43#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
44extern_conformance!(
45 unsafe impl NSCoding for NSMassFormatter {}
46);
47
48#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
49extern_conformance!(
50 unsafe impl NSCopying for NSMassFormatter {}
51);
52
53#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
54unsafe impl CopyingHelper for NSMassFormatter {
55 type Result = Self;
56}
57
58#[cfg(feature = "NSFormatter")]
59extern_conformance!(
60 unsafe impl NSObjectProtocol for NSMassFormatter {}
61);
62
63#[cfg(feature = "NSFormatter")]
64impl NSMassFormatter {
65 extern_methods!(
66 #[cfg(feature = "NSNumberFormatter")]
67 #[unsafe(method(numberFormatter))]
68 #[unsafe(method_family = none)]
69 pub fn numberFormatter(&self) -> Retained<NSNumberFormatter>;
70
71 #[cfg(feature = "NSNumberFormatter")]
72 #[unsafe(method(setNumberFormatter:))]
76 #[unsafe(method_family = none)]
77 pub fn setNumberFormatter(&self, number_formatter: Option<&NSNumberFormatter>);
78
79 #[unsafe(method(unitStyle))]
80 #[unsafe(method_family = none)]
81 pub fn unitStyle(&self) -> NSFormattingUnitStyle;
82
83 #[unsafe(method(setUnitStyle:))]
85 #[unsafe(method_family = none)]
86 pub fn setUnitStyle(&self, unit_style: NSFormattingUnitStyle);
87
88 #[unsafe(method(isForPersonMassUse))]
89 #[unsafe(method_family = none)]
90 pub fn isForPersonMassUse(&self) -> bool;
91
92 #[unsafe(method(setForPersonMassUse:))]
94 #[unsafe(method_family = none)]
95 pub fn setForPersonMassUse(&self, for_person_mass_use: bool);
96
97 #[cfg(feature = "NSString")]
98 #[unsafe(method(stringFromValue:unit:))]
99 #[unsafe(method_family = none)]
100 pub fn stringFromValue_unit(
101 &self,
102 value: c_double,
103 unit: NSMassFormatterUnit,
104 ) -> Retained<NSString>;
105
106 #[cfg(feature = "NSString")]
107 #[unsafe(method(stringFromKilograms:))]
108 #[unsafe(method_family = none)]
109 pub fn stringFromKilograms(&self, number_in_kilograms: c_double) -> Retained<NSString>;
110
111 #[cfg(feature = "NSString")]
112 #[unsafe(method(unitStringFromValue:unit:))]
113 #[unsafe(method_family = none)]
114 pub fn unitStringFromValue_unit(
115 &self,
116 value: c_double,
117 unit: NSMassFormatterUnit,
118 ) -> Retained<NSString>;
119
120 #[cfg(feature = "NSString")]
121 #[unsafe(method(unitStringFromKilograms:usedUnit:))]
125 #[unsafe(method_family = none)]
126 pub unsafe fn unitStringFromKilograms_usedUnit(
127 &self,
128 number_in_kilograms: c_double,
129 unitp: *mut NSMassFormatterUnit,
130 ) -> Retained<NSString>;
131
132 #[cfg(feature = "NSString")]
133 #[unsafe(method(getObjectValue:forString:errorDescription:))]
137 #[unsafe(method_family = none)]
138 pub unsafe fn getObjectValue_forString_errorDescription(
139 &self,
140 obj: Option<&mut Option<Retained<AnyObject>>>,
141 string: &NSString,
142 error: Option<&mut Option<Retained<NSString>>>,
143 ) -> bool;
144 );
145}
146
147#[cfg(feature = "NSFormatter")]
149impl NSMassFormatter {
150 extern_methods!(
151 #[unsafe(method(init))]
152 #[unsafe(method_family = init)]
153 pub fn init(this: Allocated<Self>) -> Retained<Self>;
154
155 #[unsafe(method(new))]
156 #[unsafe(method_family = new)]
157 pub fn new() -> Retained<Self>;
158 );
159}
160
161#[cfg(feature = "NSFormatter")]
162impl DefaultRetained for NSMassFormatter {
163 #[inline]
164 fn default_retained() -> Retained<Self> {
165 Self::new()
166 }
167}