objc2-foundation 0.2.2

Bindings to the Foundation framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;

use crate::*;

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSRelativeDateTimeFormatterStyle(pub NSInteger);
impl NSRelativeDateTimeFormatterStyle {
    #[doc(alias = "NSRelativeDateTimeFormatterStyleNumeric")]
    pub const Numeric: Self = Self(0);
    #[doc(alias = "NSRelativeDateTimeFormatterStyleNamed")]
    pub const Named: Self = Self(1);
}

unsafe impl Encode for NSRelativeDateTimeFormatterStyle {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for NSRelativeDateTimeFormatterStyle {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSRelativeDateTimeFormatterUnitsStyle(pub NSInteger);
impl NSRelativeDateTimeFormatterUnitsStyle {
    #[doc(alias = "NSRelativeDateTimeFormatterUnitsStyleFull")]
    pub const Full: Self = Self(0);
    #[doc(alias = "NSRelativeDateTimeFormatterUnitsStyleSpellOut")]
    pub const SpellOut: Self = Self(1);
    #[doc(alias = "NSRelativeDateTimeFormatterUnitsStyleShort")]
    pub const Short: Self = Self(2);
    #[doc(alias = "NSRelativeDateTimeFormatterUnitsStyleAbbreviated")]
    pub const Abbreviated: Self = Self(3);
}

unsafe impl Encode for NSRelativeDateTimeFormatterUnitsStyle {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for NSRelativeDateTimeFormatterUnitsStyle {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "NSFormatter")]
    pub struct NSRelativeDateTimeFormatter;

    #[cfg(feature = "NSFormatter")]
    unsafe impl ClassType for NSRelativeDateTimeFormatter {
        #[inherits(NSObject)]
        type Super = NSFormatter;
        type Mutability = InteriorMutable;
    }
);

#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
unsafe impl NSCoding for NSRelativeDateTimeFormatter {}

#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
unsafe impl NSCopying for NSRelativeDateTimeFormatter {}

#[cfg(feature = "NSFormatter")]
unsafe impl NSObjectProtocol for NSRelativeDateTimeFormatter {}

extern_methods!(
    #[cfg(feature = "NSFormatter")]
    unsafe impl NSRelativeDateTimeFormatter {
        #[method(dateTimeStyle)]
        pub unsafe fn dateTimeStyle(&self) -> NSRelativeDateTimeFormatterStyle;

        #[method(setDateTimeStyle:)]
        pub unsafe fn setDateTimeStyle(&self, date_time_style: NSRelativeDateTimeFormatterStyle);

        #[method(unitsStyle)]
        pub unsafe fn unitsStyle(&self) -> NSRelativeDateTimeFormatterUnitsStyle;

        #[method(setUnitsStyle:)]
        pub unsafe fn setUnitsStyle(&self, units_style: NSRelativeDateTimeFormatterUnitsStyle);

        #[method(formattingContext)]
        pub unsafe fn formattingContext(&self) -> NSFormattingContext;

        #[method(setFormattingContext:)]
        pub unsafe fn setFormattingContext(&self, formatting_context: NSFormattingContext);

        #[cfg(feature = "NSCalendar")]
        #[method_id(@__retain_semantics Other calendar)]
        pub unsafe fn calendar(&self) -> Retained<NSCalendar>;

        #[cfg(feature = "NSCalendar")]
        #[method(setCalendar:)]
        pub unsafe fn setCalendar(&self, calendar: Option<&NSCalendar>);

        #[cfg(feature = "NSLocale")]
        #[method_id(@__retain_semantics Other locale)]
        pub unsafe fn locale(&self) -> Retained<NSLocale>;

        #[cfg(feature = "NSLocale")]
        #[method(setLocale:)]
        pub unsafe fn setLocale(&self, locale: Option<&NSLocale>);

        #[cfg(all(feature = "NSCalendar", feature = "NSString"))]
        #[method_id(@__retain_semantics Other localizedStringFromDateComponents:)]
        pub unsafe fn localizedStringFromDateComponents(
            &self,
            date_components: &NSDateComponents,
        ) -> Retained<NSString>;

        #[cfg(all(feature = "NSDate", feature = "NSString"))]
        #[method_id(@__retain_semantics Other localizedStringFromTimeInterval:)]
        pub unsafe fn localizedStringFromTimeInterval(
            &self,
            time_interval: NSTimeInterval,
        ) -> Retained<NSString>;

        #[cfg(all(feature = "NSDate", feature = "NSString"))]
        #[method_id(@__retain_semantics Other localizedStringForDate:relativeToDate:)]
        pub unsafe fn localizedStringForDate_relativeToDate(
            &self,
            date: &NSDate,
            reference_date: &NSDate,
        ) -> Retained<NSString>;

        #[cfg(feature = "NSString")]
        #[method_id(@__retain_semantics Other stringForObjectValue:)]
        pub unsafe fn stringForObjectValue(
            &self,
            obj: Option<&AnyObject>,
        ) -> Option<Retained<NSString>>;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    #[cfg(feature = "NSFormatter")]
    unsafe impl NSRelativeDateTimeFormatter {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new() -> Retained<Self>;
    }
);