objc2-contacts 0.3.2

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

use crate::*;

extern_class!(
    /// A contact property that has a value and label.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/contacts/cnlabeledvalue?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct CNLabeledValue<ValueType: ?Sized = AnyObject>;
);

impl<ValueType: ?Sized + Message + NSCopying + NSSecureCoding> CNLabeledValue<ValueType> {
    /// Unchecked conversion of the generic parameter.
    ///
    /// # Safety
    ///
    /// The generic must be valid to reinterpret as the given type.
    #[inline]
    pub unsafe fn cast_unchecked<NewValueType: ?Sized + Message + NSCopying + NSSecureCoding>(
        &self,
    ) -> &CNLabeledValue<NewValueType> {
        unsafe { &*((self as *const Self).cast()) }
    }
}

extern_conformance!(
    unsafe impl<ValueType: ?Sized + NSCoding + NSCopying + NSSecureCoding> NSCoding
        for CNLabeledValue<ValueType>
    {
    }
);

extern_conformance!(
    unsafe impl<ValueType: ?Sized + NSCopying + NSSecureCoding> NSCopying
        for CNLabeledValue<ValueType>
    {
    }
);

unsafe impl<ValueType: ?Sized + Message + NSCopying + NSSecureCoding> CopyingHelper
    for CNLabeledValue<ValueType>
{
    type Result = Self;
}

extern_conformance!(
    unsafe impl<ValueType: ?Sized + NSCopying + NSSecureCoding> NSObjectProtocol
        for CNLabeledValue<ValueType>
    {
    }
);

extern_conformance!(
    unsafe impl<ValueType: ?Sized + NSSecureCoding + NSCopying + NSSecureCoding> NSSecureCoding
        for CNLabeledValue<ValueType>
    {
    }
);

impl<ValueType: Message + NSCopying + NSSecureCoding> CNLabeledValue<ValueType> {
    extern_methods!(
        /// The identifier is unique among contacts on the device. It can be saved and used for finding labeled values next application launch.
        #[unsafe(method(identifier))]
        #[unsafe(method_family = none)]
        pub unsafe fn identifier(&self) -> Retained<NSString>;

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

        #[unsafe(method(value))]
        #[unsafe(method_family = none)]
        pub unsafe fn value(&self) -> Retained<ValueType>;

        /// Returns a new CNLabeledValue with a new identifier.
        #[unsafe(method(labeledValueWithLabel:value:))]
        #[unsafe(method_family = none)]
        pub unsafe fn labeledValueWithLabel_value(
            label: Option<&NSString>,
            value: &ValueType,
        ) -> Retained<Self>;

        /// Initializes the CNLabeledValue with a new identifier.
        #[unsafe(method(initWithLabel:value:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithLabel_value(
            this: Allocated<Self>,
            label: Option<&NSString>,
            value: &ValueType,
        ) -> Retained<Self>;

        /// Returns a new CNLabeledValue with the existing value and identifier.
        #[unsafe(method(labeledValueBySettingLabel:))]
        #[unsafe(method_family = none)]
        pub unsafe fn labeledValueBySettingLabel(&self, label: Option<&NSString>)
            -> Retained<Self>;

        /// Returns a new CNLabeledValue with the existing label and identifier.
        #[unsafe(method(labeledValueBySettingValue:))]
        #[unsafe(method_family = none)]
        pub unsafe fn labeledValueBySettingValue(&self, value: &ValueType) -> Retained<Self>;

        /// Returns a new CNLabeledValue with the existing identifier.
        #[unsafe(method(labeledValueBySettingLabel:value:))]
        #[unsafe(method_family = none)]
        pub unsafe fn labeledValueBySettingLabel_value(
            &self,
            label: Option<&NSString>,
            value: &ValueType,
        ) -> Retained<Self>;

        /// Get a localized label.
        ///
        ///
        /// Some labels are special keys representing generic labels. Use this to obtain a localized string for a label to display to a user.
        ///
        ///
        /// Parameter `label`: to localize.
        ///
        /// Returns: The localized string if a Contacts framework defined label, otherwise just returns the label.
        #[unsafe(method(localizedStringForLabel:))]
        #[unsafe(method_family = none)]
        pub unsafe fn localizedStringForLabel(label: &NSString) -> Retained<NSString>;
    );
}

/// Methods declared on superclass `NSObject`.
impl<ValueType: Message + NSCopying + NSSecureCoding> CNLabeledValue<ValueType> {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cnlabelhome?language=objc)
    pub static CNLabelHome: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cnlabelwork?language=objc)
    pub static CNLabelWork: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cnlabelschool?language=objc)
    pub static CNLabelSchool: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cnlabelother?language=objc)
    pub static CNLabelOther: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cnlabelemailicloud?language=objc)
    pub static CNLabelEmailiCloud: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cnlabelurladdresshomepage?language=objc)
    pub static CNLabelURLAddressHomePage: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/contacts/cnlabeldateanniversary?language=objc)
    pub static CNLabelDateAnniversary: &'static NSString;
}