objc2_foundation/generated/
NSMassFormatter.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmassformatterunit?language=objc)
10// NS_ENUM
11#[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    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmassformatter?language=objc)
37    #[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"))]
44unsafe impl NSCoding for NSMassFormatter {}
45
46#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
47unsafe impl NSCopying for NSMassFormatter {}
48
49#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
50unsafe impl CopyingHelper for NSMassFormatter {
51    type Result = Self;
52}
53
54#[cfg(feature = "NSFormatter")]
55unsafe impl NSObjectProtocol for NSMassFormatter {}
56
57#[cfg(feature = "NSFormatter")]
58impl NSMassFormatter {
59    extern_methods!(
60        #[cfg(feature = "NSNumberFormatter")]
61        #[unsafe(method(numberFormatter))]
62        #[unsafe(method_family = none)]
63        pub unsafe fn numberFormatter(&self) -> Retained<NSNumberFormatter>;
64
65        #[cfg(feature = "NSNumberFormatter")]
66        /// Setter for [`numberFormatter`][Self::numberFormatter].
67        #[unsafe(method(setNumberFormatter:))]
68        #[unsafe(method_family = none)]
69        pub unsafe fn setNumberFormatter(&self, number_formatter: Option<&NSNumberFormatter>);
70
71        #[unsafe(method(unitStyle))]
72        #[unsafe(method_family = none)]
73        pub unsafe fn unitStyle(&self) -> NSFormattingUnitStyle;
74
75        /// Setter for [`unitStyle`][Self::unitStyle].
76        #[unsafe(method(setUnitStyle:))]
77        #[unsafe(method_family = none)]
78        pub unsafe fn setUnitStyle(&self, unit_style: NSFormattingUnitStyle);
79
80        #[unsafe(method(isForPersonMassUse))]
81        #[unsafe(method_family = none)]
82        pub unsafe fn isForPersonMassUse(&self) -> bool;
83
84        /// Setter for [`isForPersonMassUse`][Self::isForPersonMassUse].
85        #[unsafe(method(setForPersonMassUse:))]
86        #[unsafe(method_family = none)]
87        pub unsafe fn setForPersonMassUse(&self, for_person_mass_use: bool);
88
89        #[cfg(feature = "NSString")]
90        #[unsafe(method(stringFromValue:unit:))]
91        #[unsafe(method_family = none)]
92        pub unsafe fn stringFromValue_unit(
93            &self,
94            value: c_double,
95            unit: NSMassFormatterUnit,
96        ) -> Retained<NSString>;
97
98        #[cfg(feature = "NSString")]
99        #[unsafe(method(stringFromKilograms:))]
100        #[unsafe(method_family = none)]
101        pub unsafe fn stringFromKilograms(
102            &self,
103            number_in_kilograms: c_double,
104        ) -> Retained<NSString>;
105
106        #[cfg(feature = "NSString")]
107        #[unsafe(method(unitStringFromValue:unit:))]
108        #[unsafe(method_family = none)]
109        pub unsafe fn unitStringFromValue_unit(
110            &self,
111            value: c_double,
112            unit: NSMassFormatterUnit,
113        ) -> Retained<NSString>;
114
115        #[cfg(feature = "NSString")]
116        #[unsafe(method(unitStringFromKilograms:usedUnit:))]
117        #[unsafe(method_family = none)]
118        pub unsafe fn unitStringFromKilograms_usedUnit(
119            &self,
120            number_in_kilograms: c_double,
121            unitp: *mut NSMassFormatterUnit,
122        ) -> Retained<NSString>;
123
124        #[cfg(feature = "NSString")]
125        #[unsafe(method(getObjectValue:forString:errorDescription:))]
126        #[unsafe(method_family = none)]
127        pub unsafe fn getObjectValue_forString_errorDescription(
128            &self,
129            obj: Option<&mut Option<Retained<AnyObject>>>,
130            string: &NSString,
131            error: Option<&mut Option<Retained<NSString>>>,
132        ) -> bool;
133    );
134}
135
136/// Methods declared on superclass `NSObject`.
137#[cfg(feature = "NSFormatter")]
138impl NSMassFormatter {
139    extern_methods!(
140        #[unsafe(method(init))]
141        #[unsafe(method_family = init)]
142        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
143
144        #[unsafe(method(new))]
145        #[unsafe(method_family = new)]
146        pub unsafe fn new() -> Retained<Self>;
147    );
148}