objc2-foundation 0.3.2

Bindings to the Foundation framework
Documentation
//! 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::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;

use crate::*;

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nstimezone?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NSTimeZone;
);

unsafe impl Send for NSTimeZone {}

unsafe impl Sync for NSTimeZone {}

#[cfg(feature = "objc2-core-foundation")]
impl AsRef<NSTimeZone> for CFTimeZone {
    #[inline]
    fn as_ref(&self) -> &NSTimeZone {
        unsafe { &*((self as *const Self).cast()) }
    }
}

#[cfg(feature = "objc2-core-foundation")]
impl AsRef<CFTimeZone> for NSTimeZone {
    #[inline]
    fn as_ref(&self) -> &CFTimeZone {
        unsafe { &*((self as *const Self).cast()) }
    }
}

#[cfg(feature = "NSObject")]
extern_conformance!(
    unsafe impl NSCoding for NSTimeZone {}
);

#[cfg(feature = "NSObject")]
extern_conformance!(
    unsafe impl NSCopying for NSTimeZone {}
);

#[cfg(feature = "NSObject")]
unsafe impl CopyingHelper for NSTimeZone {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for NSTimeZone {}
);

#[cfg(feature = "NSObject")]
extern_conformance!(
    unsafe impl NSSecureCoding for NSTimeZone {}
);

impl NSTimeZone {
    extern_methods!(
        #[cfg(feature = "NSString")]
        #[unsafe(method(name))]
        #[unsafe(method_family = none)]
        pub fn name(&self) -> Retained<NSString>;

        #[cfg(feature = "NSData")]
        #[unsafe(method(data))]
        #[unsafe(method_family = none)]
        pub fn data(&self) -> Retained<NSData>;

        #[cfg(feature = "NSDate")]
        #[unsafe(method(secondsFromGMTForDate:))]
        #[unsafe(method_family = none)]
        pub fn secondsFromGMTForDate(&self, a_date: &NSDate) -> NSInteger;

        #[cfg(all(feature = "NSDate", feature = "NSString"))]
        #[unsafe(method(abbreviationForDate:))]
        #[unsafe(method_family = none)]
        pub fn abbreviationForDate(&self, a_date: &NSDate) -> Option<Retained<NSString>>;

        #[cfg(feature = "NSDate")]
        #[unsafe(method(isDaylightSavingTimeForDate:))]
        #[unsafe(method_family = none)]
        pub fn isDaylightSavingTimeForDate(&self, a_date: &NSDate) -> bool;

        #[cfg(feature = "NSDate")]
        #[unsafe(method(daylightSavingTimeOffsetForDate:))]
        #[unsafe(method_family = none)]
        pub fn daylightSavingTimeOffsetForDate(&self, a_date: &NSDate) -> NSTimeInterval;

        #[cfg(feature = "NSDate")]
        #[unsafe(method(nextDaylightSavingTimeTransitionAfterDate:))]
        #[unsafe(method_family = none)]
        pub fn nextDaylightSavingTimeTransitionAfterDate(
            &self,
            a_date: &NSDate,
        ) -> Option<Retained<NSDate>>;
    );
}

/// Methods declared on superclass `NSObject`.
impl NSTimeZone {
    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>;
    );
}

impl DefaultRetained for NSTimeZone {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}

/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nstimezonenamestyle?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSTimeZoneNameStyle(pub NSInteger);
impl NSTimeZoneNameStyle {
    #[doc(alias = "NSTimeZoneNameStyleStandard")]
    pub const Standard: Self = Self(0);
    #[doc(alias = "NSTimeZoneNameStyleShortStandard")]
    pub const ShortStandard: Self = Self(1);
    #[doc(alias = "NSTimeZoneNameStyleDaylightSaving")]
    pub const DaylightSaving: Self = Self(2);
    #[doc(alias = "NSTimeZoneNameStyleShortDaylightSaving")]
    pub const ShortDaylightSaving: Self = Self(3);
    #[doc(alias = "NSTimeZoneNameStyleGeneric")]
    pub const Generic: Self = Self(4);
    #[doc(alias = "NSTimeZoneNameStyleShortGeneric")]
    pub const ShortGeneric: Self = Self(5);
}

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

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

/// NSExtendedTimeZone.
impl NSTimeZone {
    extern_methods!(
        #[unsafe(method(systemTimeZone))]
        #[unsafe(method_family = none)]
        pub fn systemTimeZone() -> Retained<NSTimeZone>;

        #[unsafe(method(resetSystemTimeZone))]
        #[unsafe(method_family = none)]
        pub fn resetSystemTimeZone();

        #[unsafe(method(defaultTimeZone))]
        #[unsafe(method_family = none)]
        pub fn defaultTimeZone() -> Retained<NSTimeZone>;

        /// Setter for [`defaultTimeZone`][Self::defaultTimeZone].
        ///
        /// This is [copied][crate::NSCopying::copy] when set.
        #[unsafe(method(setDefaultTimeZone:))]
        #[unsafe(method_family = none)]
        pub fn setDefaultTimeZone(default_time_zone: &NSTimeZone);

        #[unsafe(method(localTimeZone))]
        #[unsafe(method_family = none)]
        pub fn localTimeZone() -> Retained<NSTimeZone>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[unsafe(method(knownTimeZoneNames))]
        #[unsafe(method_family = none)]
        pub fn knownTimeZoneNames() -> Retained<NSArray<NSString>>;

        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
        #[unsafe(method(abbreviationDictionary))]
        #[unsafe(method_family = none)]
        pub fn abbreviationDictionary() -> Retained<NSDictionary<NSString, NSString>>;

        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
        /// Setter for [`abbreviationDictionary`][Self::abbreviationDictionary].
        ///
        /// This is [copied][crate::NSCopying::copy] when set.
        #[unsafe(method(setAbbreviationDictionary:))]
        #[unsafe(method_family = none)]
        pub fn setAbbreviationDictionary(
            abbreviation_dictionary: &NSDictionary<NSString, NSString>,
        );

        #[cfg(feature = "NSString")]
        #[unsafe(method(timeZoneDataVersion))]
        #[unsafe(method_family = none)]
        pub fn timeZoneDataVersion() -> Retained<NSString>;

        #[unsafe(method(secondsFromGMT))]
        #[unsafe(method_family = none)]
        pub fn secondsFromGMT(&self) -> NSInteger;

        #[cfg(feature = "NSString")]
        #[unsafe(method(abbreviation))]
        #[unsafe(method_family = none)]
        pub fn abbreviation(&self) -> Option<Retained<NSString>>;

        #[unsafe(method(isDaylightSavingTime))]
        #[unsafe(method_family = none)]
        pub fn isDaylightSavingTime(&self) -> bool;

        #[cfg(feature = "NSDate")]
        #[unsafe(method(daylightSavingTimeOffset))]
        #[unsafe(method_family = none)]
        pub fn daylightSavingTimeOffset(&self) -> NSTimeInterval;

        #[cfg(feature = "NSDate")]
        #[unsafe(method(nextDaylightSavingTimeTransition))]
        #[unsafe(method_family = none)]
        pub fn nextDaylightSavingTimeTransition(&self) -> Option<Retained<NSDate>>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(description))]
        #[unsafe(method_family = none)]
        pub fn description(&self) -> Retained<NSString>;

        #[unsafe(method(isEqualToTimeZone:))]
        #[unsafe(method_family = none)]
        pub fn isEqualToTimeZone(&self, a_time_zone: &NSTimeZone) -> bool;

        #[cfg(all(feature = "NSLocale", feature = "NSString"))]
        #[unsafe(method(localizedName:locale:))]
        #[unsafe(method_family = none)]
        pub fn localizedName_locale(
            &self,
            style: NSTimeZoneNameStyle,
            locale: Option<&NSLocale>,
        ) -> Option<Retained<NSString>>;
    );
}

/// NSTimeZoneCreation.
impl NSTimeZone {
    extern_methods!(
        #[cfg(feature = "NSString")]
        #[unsafe(method(timeZoneWithName:))]
        #[unsafe(method_family = none)]
        pub fn timeZoneWithName(tz_name: &NSString) -> Option<Retained<Self>>;

        #[cfg(all(feature = "NSData", feature = "NSString"))]
        #[unsafe(method(timeZoneWithName:data:))]
        #[unsafe(method_family = none)]
        pub fn timeZoneWithName_data(
            tz_name: &NSString,
            a_data: Option<&NSData>,
        ) -> Option<Retained<Self>>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(initWithName:))]
        #[unsafe(method_family = init)]
        pub fn initWithName(this: Allocated<Self>, tz_name: &NSString) -> Option<Retained<Self>>;

        #[cfg(all(feature = "NSData", feature = "NSString"))]
        #[unsafe(method(initWithName:data:))]
        #[unsafe(method_family = init)]
        pub fn initWithName_data(
            this: Allocated<Self>,
            tz_name: &NSString,
            a_data: Option<&NSData>,
        ) -> Option<Retained<Self>>;

        #[unsafe(method(timeZoneForSecondsFromGMT:))]
        #[unsafe(method_family = none)]
        pub fn timeZoneForSecondsFromGMT(seconds: NSInteger) -> Retained<Self>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(timeZoneWithAbbreviation:))]
        #[unsafe(method_family = none)]
        pub fn timeZoneWithAbbreviation(abbreviation: &NSString) -> Option<Retained<Self>>;
    );
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nssystemtimezonedidchangenotification?language=objc)
    #[cfg(all(feature = "NSNotification", feature = "NSString"))]
    pub static NSSystemTimeZoneDidChangeNotification: &'static NSNotificationName;
}