//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use crate::common::*;
use crate::BackgroundAssets::*;
use crate::Foundation::*;

extern_protocol!(
    pub unsafe trait BADownloadManagerDelegate: NSObjectProtocol {
        #[cfg(feature = "BackgroundAssets_BADownload")]
        #[optional]
        #[method(downloadDidBegin:)]
        unsafe fn downloadDidBegin(&self, download: &BADownload);

        #[cfg(feature = "BackgroundAssets_BADownload")]
        #[optional]
        #[method(downloadDidPause:)]
        unsafe fn downloadDidPause(&self, download: &BADownload);

        #[cfg(feature = "BackgroundAssets_BADownload")]
        #[optional]
        #[method(download:didWriteBytes:totalBytesWritten:totalBytesExpectedToWrite:)]
        unsafe fn download_didWriteBytes_totalBytesWritten_totalBytesExpectedToWrite(
            &self,
            download: &BADownload,
            bytes_written: i64,
            total_bytes_written: i64,
            total_expected_bytes: i64,
        );

        #[cfg(all(
            feature = "BackgroundAssets_BADownload",
            feature = "Foundation_NSURLAuthenticationChallenge",
            feature = "Foundation_NSURLCredential"
        ))]
        #[optional]
        #[method(download:didReceiveChallenge:completionHandler:)]
        unsafe fn download_didReceiveChallenge_completionHandler(
            &self,
            download: &BADownload,
            challenge: &NSURLAuthenticationChallenge,
            completion_handler: &Block<
                (NSURLSessionAuthChallengeDisposition, *mut NSURLCredential),
                (),
            >,
        );

        #[cfg(all(
            feature = "BackgroundAssets_BADownload",
            feature = "Foundation_NSError"
        ))]
        #[optional]
        #[method(download:failedWithError:)]
        unsafe fn download_failedWithError(&self, download: &BADownload, error: &NSError);

        #[cfg(all(feature = "BackgroundAssets_BADownload", feature = "Foundation_NSURL"))]
        #[optional]
        #[method(download:finishedWithFileURL:)]
        unsafe fn download_finishedWithFileURL(&self, download: &BADownload, file_url: &NSURL);
    }

    unsafe impl ProtocolType for dyn BADownloadManagerDelegate {}
);

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

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

#[cfg(feature = "BackgroundAssets_BADownloadManager")]
unsafe impl NSObjectProtocol for BADownloadManager {}

extern_methods!(
    #[cfg(feature = "BackgroundAssets_BADownloadManager")]
    unsafe impl BADownloadManager {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Option<Allocated<Self>>) -> Id<Self>;

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

        #[method_id(@__retain_semantics Other sharedManager)]
        pub unsafe fn sharedManager() -> Id<BADownloadManager>;

        #[method_id(@__retain_semantics Other delegate)]
        pub unsafe fn delegate(&self) -> Option<Id<ProtocolObject<dyn BADownloadManagerDelegate>>>;

        #[method(setDelegate:)]
        pub unsafe fn setDelegate(
            &self,
            delegate: Option<&ProtocolObject<dyn BADownloadManagerDelegate>>,
        );

        #[cfg(all(
            feature = "BackgroundAssets_BADownload",
            feature = "Foundation_NSArray",
            feature = "Foundation_NSError"
        ))]
        #[method(fetchCurrentDownloadsWithCompletionHandler:)]
        pub unsafe fn fetchCurrentDownloadsWithCompletionHandler(
            &self,
            completion_handler: &Block<(NonNull<NSArray<BADownload>>, *mut NSError), ()>,
        );

        #[cfg(all(
            feature = "BackgroundAssets_BADownload",
            feature = "Foundation_NSError"
        ))]
        #[method(scheduleDownload:error:_)]
        pub unsafe fn scheduleDownload_error(
            &self,
            download: &BADownload,
        ) -> Result<(), Id<NSError>>;

        #[cfg(feature = "Foundation_NSError")]
        #[method(performWithExclusiveControl:)]
        pub unsafe fn performWithExclusiveControl(
            &self,
            perform_handler: &Block<(Bool, *mut NSError), ()>,
        );

        #[cfg(all(feature = "Foundation_NSDate", feature = "Foundation_NSError"))]
        #[method(performWithExclusiveControlBeforeDate:performHandler:)]
        pub unsafe fn performWithExclusiveControlBeforeDate_performHandler(
            &self,
            date: &NSDate,
            perform_handler: &Block<(Bool, *mut NSError), ()>,
        );

        #[cfg(all(
            feature = "BackgroundAssets_BADownload",
            feature = "Foundation_NSError"
        ))]
        #[method(startForegroundDownload:error:_)]
        pub unsafe fn startForegroundDownload_error(
            &self,
            download: &BADownload,
        ) -> Result<(), Id<NSError>>;

        #[cfg(all(
            feature = "BackgroundAssets_BADownload",
            feature = "Foundation_NSError"
        ))]
        #[method(cancelDownload:error:_)]
        pub unsafe fn cancelDownload_error(&self, download: &BADownload)
            -> Result<(), Id<NSError>>;
    }
);
