objc2-foundation 0.2.2

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

use crate::*;

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NSURLDownload;

    unsafe impl ClassType for NSURLDownload {
        type Super = NSObject;
        type Mutability = InteriorMutable;
    }
);

unsafe impl NSObjectProtocol for NSURLDownload {}

extern_methods!(
    unsafe impl NSURLDownload {
        #[cfg(feature = "NSString")]
        #[method(canResumeDownloadDecodedWithEncodingMIMEType:)]
        pub unsafe fn canResumeDownloadDecodedWithEncodingMIMEType(mime_type: &NSString) -> bool;

        #[cfg(feature = "NSURLRequest")]
        #[deprecated = "Use NSURLSession downloadTask (see NSURLSession.h)"]
        #[method_id(@__retain_semantics Init initWithRequest:delegate:)]
        pub unsafe fn initWithRequest_delegate(
            this: Allocated<Self>,
            request: &NSURLRequest,
            delegate: Option<&ProtocolObject<dyn NSURLDownloadDelegate>>,
        ) -> Retained<Self>;

        #[cfg(all(feature = "NSData", feature = "NSString"))]
        #[deprecated = "Use NSURLSession downloadTask (see NSURLSession.h)"]
        #[method_id(@__retain_semantics Init initWithResumeData:delegate:path:)]
        pub unsafe fn initWithResumeData_delegate_path(
            this: Allocated<Self>,
            resume_data: &NSData,
            delegate: Option<&ProtocolObject<dyn NSURLDownloadDelegate>>,
            path: &NSString,
        ) -> Retained<Self>;

        #[method(cancel)]
        pub unsafe fn cancel(&self);

        #[cfg(feature = "NSString")]
        #[method(setDestination:allowOverwrite:)]
        pub unsafe fn setDestination_allowOverwrite(&self, path: &NSString, allow_overwrite: bool);

        #[cfg(feature = "NSURLRequest")]
        #[method_id(@__retain_semantics Other request)]
        pub unsafe fn request(&self) -> Retained<NSURLRequest>;

        #[cfg(feature = "NSData")]
        #[method_id(@__retain_semantics Other resumeData)]
        pub unsafe fn resumeData(&self) -> Option<Retained<NSData>>;

        #[method(deletesFileUponFailure)]
        pub unsafe fn deletesFileUponFailure(&self) -> bool;

        #[method(setDeletesFileUponFailure:)]
        pub unsafe fn setDeletesFileUponFailure(&self, deletes_file_upon_failure: bool);
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl NSURLDownload {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

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

extern_protocol!(
    pub unsafe trait NSURLDownloadDelegate: NSObjectProtocol {
        #[optional]
        #[method(downloadDidBegin:)]
        unsafe fn downloadDidBegin(&self, download: &NSURLDownload);

        #[cfg(all(feature = "NSURLRequest", feature = "NSURLResponse"))]
        #[optional]
        #[method_id(@__retain_semantics Other download:willSendRequest:redirectResponse:)]
        unsafe fn download_willSendRequest_redirectResponse(
            &self,
            download: &NSURLDownload,
            request: &NSURLRequest,
            redirect_response: Option<&NSURLResponse>,
        ) -> Option<Retained<NSURLRequest>>;

        #[cfg(feature = "NSURLProtectionSpace")]
        #[optional]
        #[method(download:canAuthenticateAgainstProtectionSpace:)]
        unsafe fn download_canAuthenticateAgainstProtectionSpace(
            &self,
            connection: &NSURLDownload,
            protection_space: &NSURLProtectionSpace,
        ) -> bool;

        #[cfg(feature = "NSURLAuthenticationChallenge")]
        #[optional]
        #[method(download:didReceiveAuthenticationChallenge:)]
        unsafe fn download_didReceiveAuthenticationChallenge(
            &self,
            download: &NSURLDownload,
            challenge: &NSURLAuthenticationChallenge,
        );

        #[cfg(feature = "NSURLAuthenticationChallenge")]
        #[optional]
        #[method(download:didCancelAuthenticationChallenge:)]
        unsafe fn download_didCancelAuthenticationChallenge(
            &self,
            download: &NSURLDownload,
            challenge: &NSURLAuthenticationChallenge,
        );

        #[optional]
        #[method(downloadShouldUseCredentialStorage:)]
        unsafe fn downloadShouldUseCredentialStorage(&self, download: &NSURLDownload) -> bool;

        #[cfg(feature = "NSURLResponse")]
        #[optional]
        #[method(download:didReceiveResponse:)]
        unsafe fn download_didReceiveResponse(
            &self,
            download: &NSURLDownload,
            response: &NSURLResponse,
        );

        #[cfg(feature = "NSURLResponse")]
        #[optional]
        #[method(download:willResumeWithResponse:fromByte:)]
        unsafe fn download_willResumeWithResponse_fromByte(
            &self,
            download: &NSURLDownload,
            response: &NSURLResponse,
            starting_byte: c_longlong,
        );

        #[optional]
        #[method(download:didReceiveDataOfLength:)]
        unsafe fn download_didReceiveDataOfLength(
            &self,
            download: &NSURLDownload,
            length: NSUInteger,
        );

        #[cfg(feature = "NSString")]
        #[optional]
        #[method(download:shouldDecodeSourceDataOfMIMEType:)]
        unsafe fn download_shouldDecodeSourceDataOfMIMEType(
            &self,
            download: &NSURLDownload,
            encoding_type: &NSString,
        ) -> bool;

        #[cfg(feature = "NSString")]
        #[optional]
        #[method(download:decideDestinationWithSuggestedFilename:)]
        unsafe fn download_decideDestinationWithSuggestedFilename(
            &self,
            download: &NSURLDownload,
            filename: &NSString,
        );

        #[cfg(feature = "NSString")]
        #[optional]
        #[method(download:didCreateDestination:)]
        unsafe fn download_didCreateDestination(&self, download: &NSURLDownload, path: &NSString);

        #[optional]
        #[method(downloadDidFinish:)]
        unsafe fn downloadDidFinish(&self, download: &NSURLDownload);

        #[cfg(feature = "NSError")]
        #[optional]
        #[method(download:didFailWithError:)]
        unsafe fn download_didFailWithError(&self, download: &NSURLDownload, error: &NSError);
    }

    unsafe impl ProtocolType for dyn NSURLDownloadDelegate {}
);