objc2-ad-services 0.3.2

Bindings to the AdServices 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 "C" {
    /// The framework attribution error domain.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/adservices/aaattributionerrordomain?language=objc)
    pub static AAAttributionErrorDomain: &'static NSErrorDomain;
}

/// The error codes that may be returned by AAAttribution.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/adservices/aaattributionerrorcode?language=objc)
// NS_ERROR_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct AAAttributionErrorCode(pub NSInteger);
impl AAAttributionErrorCode {
    /// attributionTokenWithError: is unable to provide a token because the internet isn’t available.
    ///
    /// To receive an attribution token, you must have unimpeded internet access. Make sure
    /// you’re not using a simulator when generating a token.
    #[doc(alias = "AAAttributionErrorCodeNetworkError")]
    pub const NetworkError: Self = Self(1);
    /// attributionTokenWithError: is unable to provide a token because of an internal error.
    #[doc(alias = "AAAttributionErrorCodeInternalError")]
    pub const InternalError: Self = Self(2);
    /// attributionTokenWithError: is unable to provide a token because of an unsupported operating system.
    #[doc(alias = "AAAttributionErrorCodePlatformNotSupported")]
    pub const PlatformNotSupported: Self = Self(3);
}

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

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

extern_class!(
    /// The parent class that the framework uses to request a token.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/adservices/aaattribution?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct AAAttribution;
);

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

impl AAAttribution {
    extern_methods!(
        /// Generates a token.
        #[unsafe(method(attributionTokenWithError:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn attributionTokenWithError() -> Result<Retained<NSString>, Retained<NSError>>;
    );
}

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