//! 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::*;

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nshttppropertystatuscodekey?language=objc)
    #[cfg(feature = "NSString")]
    #[deprecated]
    pub static NSHTTPPropertyStatusCodeKey: Option<&'static NSString>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nshttppropertystatusreasonkey?language=objc)
    #[cfg(feature = "NSString")]
    #[deprecated]
    pub static NSHTTPPropertyStatusReasonKey: Option<&'static NSString>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nshttppropertyserverhttpversionkey?language=objc)
    #[cfg(feature = "NSString")]
    #[deprecated]
    pub static NSHTTPPropertyServerHTTPVersionKey: Option<&'static NSString>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nshttppropertyredirectionheaderskey?language=objc)
    #[cfg(feature = "NSString")]
    #[deprecated]
    pub static NSHTTPPropertyRedirectionHeadersKey: Option<&'static NSString>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nshttppropertyerrorpagedatakey?language=objc)
    #[cfg(feature = "NSString")]
    #[deprecated]
    pub static NSHTTPPropertyErrorPageDataKey: Option<&'static NSString>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nshttppropertyhttpproxy?language=objc)
    #[cfg(feature = "NSString")]
    #[deprecated]
    pub static NSHTTPPropertyHTTPProxy: Option<&'static NSString>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsftppropertyuserloginkey?language=objc)
    #[cfg(feature = "NSString")]
    #[deprecated]
    pub static NSFTPPropertyUserLoginKey: Option<&'static NSString>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsftppropertyuserpasswordkey?language=objc)
    #[cfg(feature = "NSString")]
    #[deprecated]
    pub static NSFTPPropertyUserPasswordKey: Option<&'static NSString>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsftppropertyactivetransfermodekey?language=objc)
    #[cfg(feature = "NSString")]
    #[deprecated]
    pub static NSFTPPropertyActiveTransferModeKey: Option<&'static NSString>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsftppropertyfileoffsetkey?language=objc)
    #[cfg(feature = "NSString")]
    #[deprecated]
    pub static NSFTPPropertyFileOffsetKey: Option<&'static NSString>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsftppropertyftpproxy?language=objc)
    #[cfg(feature = "NSString")]
    #[deprecated]
    pub static NSFTPPropertyFTPProxy: Option<&'static NSString>;
}

/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlhandlestatus?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSURLHandleStatus(pub NSUInteger);
impl NSURLHandleStatus {
    #[doc(alias = "NSURLHandleNotLoaded")]
    pub const NotLoaded: Self = Self(0);
    #[doc(alias = "NSURLHandleLoadSucceeded")]
    pub const LoadSucceeded: Self = Self(1);
    #[doc(alias = "NSURLHandleLoadInProgress")]
    pub const LoadInProgress: Self = Self(2);
    #[doc(alias = "NSURLHandleLoadFailed")]
    pub const LoadFailed: Self = Self(3);
}

unsafe impl Encode for NSURLHandleStatus {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

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

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlhandleclient?language=objc)
    #[deprecated]
    pub unsafe trait NSURLHandleClient {
        #[cfg(feature = "NSData")]
        /// # Safety
        ///
        /// - `sender` might not allow `None`.
        /// - `new_bytes` might not allow `None`.
        #[deprecated]
        #[unsafe(method(URLHandle:resourceDataDidBecomeAvailable:))]
        #[unsafe(method_family = none)]
        unsafe fn URLHandle_resourceDataDidBecomeAvailable(
            &self,
            sender: Option<&NSURLHandle>,
            new_bytes: Option<&NSData>,
        );

        /// # Safety
        ///
        /// `sender` might not allow `None`.
        #[deprecated]
        #[unsafe(method(URLHandleResourceDidBeginLoading:))]
        #[unsafe(method_family = none)]
        unsafe fn URLHandleResourceDidBeginLoading(&self, sender: Option<&NSURLHandle>);

        /// # Safety
        ///
        /// `sender` might not allow `None`.
        #[deprecated]
        #[unsafe(method(URLHandleResourceDidFinishLoading:))]
        #[unsafe(method_family = none)]
        unsafe fn URLHandleResourceDidFinishLoading(&self, sender: Option<&NSURLHandle>);

        /// # Safety
        ///
        /// `sender` might not allow `None`.
        #[deprecated]
        #[unsafe(method(URLHandleResourceDidCancelLoading:))]
        #[unsafe(method_family = none)]
        unsafe fn URLHandleResourceDidCancelLoading(&self, sender: Option<&NSURLHandle>);

        #[cfg(feature = "NSString")]
        /// # Safety
        ///
        /// - `sender` might not allow `None`.
        /// - `reason` might not allow `None`.
        #[deprecated]
        #[unsafe(method(URLHandle:resourceDidFailLoadingWithReason:))]
        #[unsafe(method_family = none)]
        unsafe fn URLHandle_resourceDidFailLoadingWithReason(
            &self,
            sender: Option<&NSURLHandle>,
            reason: Option<&NSString>,
        );
    }
);

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

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

impl NSURLHandle {
    extern_methods!(
        /// # Safety
        ///
        /// - `an_url_handle_subclass` probably has further requirements.
        /// - `an_url_handle_subclass` might not allow `None`.
        #[deprecated]
        #[unsafe(method(registerURLHandleClass:))]
        #[unsafe(method_family = none)]
        pub unsafe fn registerURLHandleClass(an_url_handle_subclass: Option<&AnyClass>);

        #[cfg(feature = "NSURL")]
        /// # Safety
        ///
        /// `an_url` might not allow `None`.
        #[deprecated]
        #[unsafe(method(URLHandleClassForURL:))]
        #[unsafe(method_family = none)]
        pub unsafe fn URLHandleClassForURL(an_url: Option<&NSURL>) -> Option<&'static AnyClass>;

        #[deprecated]
        #[unsafe(method(status))]
        #[unsafe(method_family = none)]
        pub fn status(&self) -> NSURLHandleStatus;

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

        /// # Safety
        ///
        /// `client` might not allow `None`.
        #[deprecated]
        #[unsafe(method(addClient:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addClient(&self, client: Option<&ProtocolObject<dyn NSURLHandleClient>>);

        /// # Safety
        ///
        /// `client` might not allow `None`.
        #[deprecated]
        #[unsafe(method(removeClient:))]
        #[unsafe(method_family = none)]
        pub unsafe fn removeClient(&self, client: Option<&ProtocolObject<dyn NSURLHandleClient>>);

        #[deprecated]
        #[unsafe(method(loadInBackground))]
        #[unsafe(method_family = none)]
        pub fn loadInBackground(&self);

        #[deprecated]
        #[unsafe(method(cancelLoadInBackground))]
        #[unsafe(method_family = none)]
        pub fn cancelLoadInBackground(&self);

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

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

        #[deprecated]
        #[unsafe(method(expectedResourceDataSize))]
        #[unsafe(method_family = none)]
        pub fn expectedResourceDataSize(&self) -> c_longlong;

        #[deprecated]
        #[unsafe(method(flushCachedData))]
        #[unsafe(method_family = none)]
        pub fn flushCachedData(&self);

        #[cfg(feature = "NSString")]
        /// # Safety
        ///
        /// `reason` might not allow `None`.
        #[deprecated]
        #[unsafe(method(backgroundLoadDidFailWithReason:))]
        #[unsafe(method_family = none)]
        pub unsafe fn backgroundLoadDidFailWithReason(&self, reason: Option<&NSString>);

        #[cfg(feature = "NSData")]
        /// # Safety
        ///
        /// `new_bytes` might not allow `None`.
        #[deprecated]
        #[unsafe(method(didLoadBytes:loadComplete:))]
        #[unsafe(method_family = none)]
        pub unsafe fn didLoadBytes_loadComplete(&self, new_bytes: Option<&NSData>, yorn: bool);

        #[cfg(feature = "NSURL")]
        /// # Safety
        ///
        /// `an_url` might not allow `None`.
        #[deprecated]
        #[unsafe(method(canInitWithURL:))]
        #[unsafe(method_family = none)]
        pub unsafe fn canInitWithURL(an_url: Option<&NSURL>) -> bool;

        #[cfg(feature = "NSURL")]
        /// # Safety
        ///
        /// `an_url` might not allow `None`.
        #[deprecated]
        #[unsafe(method(cachedHandleForURL:))]
        #[unsafe(method_family = none)]
        pub unsafe fn cachedHandleForURL(an_url: Option<&NSURL>) -> Option<Retained<NSURLHandle>>;

        #[cfg(feature = "NSURL")]
        /// # Safety
        ///
        /// `an_url` might not allow `None`.
        #[deprecated]
        #[unsafe(method(initWithURL:cached:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithURL_cached(
            this: Allocated<Self>,
            an_url: Option<&NSURL>,
            will_cache: bool,
        ) -> Option<Retained<Self>>;

        #[cfg(feature = "NSString")]
        /// # Safety
        ///
        /// `property_key` might not allow `None`.
        #[deprecated]
        #[unsafe(method(propertyForKey:))]
        #[unsafe(method_family = none)]
        pub unsafe fn propertyForKey(
            &self,
            property_key: Option<&NSString>,
        ) -> Option<Retained<AnyObject>>;

        #[cfg(feature = "NSString")]
        /// # Safety
        ///
        /// `property_key` might not allow `None`.
        #[deprecated]
        #[unsafe(method(propertyForKeyIfAvailable:))]
        #[unsafe(method_family = none)]
        pub unsafe fn propertyForKeyIfAvailable(
            &self,
            property_key: Option<&NSString>,
        ) -> Option<Retained<AnyObject>>;

        #[cfg(feature = "NSString")]
        /// # Safety
        ///
        /// - `property_value` should be of the correct type.
        /// - `property_value` might not allow `None`.
        /// - `property_key` might not allow `None`.
        #[deprecated]
        #[unsafe(method(writeProperty:forKey:))]
        #[unsafe(method_family = none)]
        pub unsafe fn writeProperty_forKey(
            &self,
            property_value: Option<&AnyObject>,
            property_key: Option<&NSString>,
        ) -> bool;

        #[cfg(feature = "NSData")]
        /// # Safety
        ///
        /// `data` might not allow `None`.
        #[deprecated]
        #[unsafe(method(writeData:))]
        #[unsafe(method_family = none)]
        pub unsafe fn writeData(&self, data: Option<&NSData>) -> bool;

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

        #[deprecated]
        #[unsafe(method(beginLoadInBackground))]
        #[unsafe(method_family = none)]
        pub fn beginLoadInBackground(&self);

        #[deprecated]
        #[unsafe(method(endLoadInBackground))]
        #[unsafe(method_family = none)]
        pub fn endLoadInBackground(&self);
    );
}

/// Methods declared on superclass `NSObject`.
impl NSURLHandle {
    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 NSURLHandle {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}
