Source code

Revision control

Copy as Markdown

Other Tools

//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use crate::*;
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSMassFormatterUnit(pub NSInteger);
impl NSMassFormatterUnit {
#[doc(alias = "NSMassFormatterUnitGram")]
pub const Gram: Self = Self(11);
#[doc(alias = "NSMassFormatterUnitKilogram")]
pub const Kilogram: Self = Self(14);
#[doc(alias = "NSMassFormatterUnitOunce")]
pub const Ounce: Self = Self((6 << 8) + 1);
#[doc(alias = "NSMassFormatterUnitPound")]
pub const Pound: Self = Self((6 << 8) + 2);
#[doc(alias = "NSMassFormatterUnitStone")]
pub const Stone: Self = Self((6 << 8) + 3);
}
unsafe impl Encode for NSMassFormatterUnit {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for NSMassFormatterUnit {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
#[unsafe(super(NSFormatter, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
#[cfg(feature = "NSFormatter")]
pub struct NSMassFormatter;
);
#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
extern_conformance!(
unsafe impl NSCoding for NSMassFormatter {}
);
#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
extern_conformance!(
unsafe impl NSCopying for NSMassFormatter {}
);
#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
unsafe impl CopyingHelper for NSMassFormatter {
type Result = Self;
}
#[cfg(feature = "NSFormatter")]
extern_conformance!(
unsafe impl NSObjectProtocol for NSMassFormatter {}
);
#[cfg(feature = "NSFormatter")]
impl NSMassFormatter {
extern_methods!(
#[cfg(feature = "NSNumberFormatter")]
#[unsafe(method(numberFormatter))]
#[unsafe(method_family = none)]
pub fn numberFormatter(&self) -> Retained<NSNumberFormatter>;
#[cfg(feature = "NSNumberFormatter")]
/// Setter for [`numberFormatter`][Self::numberFormatter].
///
/// This is [copied][crate::NSCopying::copy] when set.
#[unsafe(method(setNumberFormatter:))]
#[unsafe(method_family = none)]
pub fn setNumberFormatter(&self, number_formatter: Option<&NSNumberFormatter>);
#[unsafe(method(unitStyle))]
#[unsafe(method_family = none)]
pub fn unitStyle(&self) -> NSFormattingUnitStyle;
/// Setter for [`unitStyle`][Self::unitStyle].
#[unsafe(method(setUnitStyle:))]
#[unsafe(method_family = none)]
pub fn setUnitStyle(&self, unit_style: NSFormattingUnitStyle);
#[unsafe(method(isForPersonMassUse))]
#[unsafe(method_family = none)]
pub fn isForPersonMassUse(&self) -> bool;
/// Setter for [`isForPersonMassUse`][Self::isForPersonMassUse].
#[unsafe(method(setForPersonMassUse:))]
#[unsafe(method_family = none)]
pub fn setForPersonMassUse(&self, for_person_mass_use: bool);
#[cfg(feature = "NSString")]
#[unsafe(method(stringFromValue:unit:))]
#[unsafe(method_family = none)]
pub fn stringFromValue_unit(
&self,
value: c_double,
unit: NSMassFormatterUnit,
) -> Retained<NSString>;
#[cfg(feature = "NSString")]
#[unsafe(method(stringFromKilograms:))]
#[unsafe(method_family = none)]
pub fn stringFromKilograms(&self, number_in_kilograms: c_double) -> Retained<NSString>;
#[cfg(feature = "NSString")]
#[unsafe(method(unitStringFromValue:unit:))]
#[unsafe(method_family = none)]
pub fn unitStringFromValue_unit(
&self,
value: c_double,
unit: NSMassFormatterUnit,
) -> Retained<NSString>;
#[cfg(feature = "NSString")]
/// # Safety
///
/// `unitp` must be a valid pointer or null.
#[unsafe(method(unitStringFromKilograms:usedUnit:))]
#[unsafe(method_family = none)]
pub unsafe fn unitStringFromKilograms_usedUnit(
&self,
number_in_kilograms: c_double,
unitp: *mut NSMassFormatterUnit,
) -> Retained<NSString>;
#[cfg(feature = "NSString")]
/// # Safety
///
/// `obj` should be of the correct type.
#[unsafe(method(getObjectValue:forString:errorDescription:))]
#[unsafe(method_family = none)]
pub unsafe fn getObjectValue_forString_errorDescription(
&self,
obj: Option<&mut Option<Retained<AnyObject>>>,
string: &NSString,
error: Option<&mut Option<Retained<NSString>>>,
) -> bool;
);
}
/// Methods declared on superclass `NSObject`.
#[cfg(feature = "NSFormatter")]
impl NSMassFormatter {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub fn new() -> Retained<Self>;
);
}
#[cfg(feature = "NSFormatter")]
impl DefaultRetained for NSMassFormatter {
#[inline]
fn default_retained() -> Retained<Self> {
Self::new()
}
}