1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct WKDownloadRedirectPolicy(pub NSInteger);
impl WKDownloadRedirectPolicy {
    #[doc(alias = "WKDownloadRedirectPolicyCancel")]
    pub const Cancel: Self = Self(0);
    #[doc(alias = "WKDownloadRedirectPolicyAllow")]
    pub const Allow: Self = Self(1);
}

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

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

extern_protocol!(
    pub unsafe trait WKDownloadDelegate: NSObjectProtocol {
        #[cfg(all(feature = "WKDownload", feature = "block2"))]
        #[method(download:decideDestinationUsingResponse:suggestedFilename:completionHandler:)]
        unsafe fn download_decideDestinationUsingResponse_suggestedFilename_completionHandler(
            &self,
            download: &WKDownload,
            response: &NSURLResponse,
            suggested_filename: &NSString,
            completion_handler: &block2::Block<dyn Fn(*mut NSURL)>,
        );

        #[cfg(all(feature = "WKDownload", feature = "block2"))]
        #[optional]
        #[method(download:willPerformHTTPRedirection:newRequest:decisionHandler:)]
        unsafe fn download_willPerformHTTPRedirection_newRequest_decisionHandler(
            &self,
            download: &WKDownload,
            response: &NSHTTPURLResponse,
            request: &NSURLRequest,
            decision_handler: &block2::Block<dyn Fn(WKDownloadRedirectPolicy)>,
        );

        #[cfg(all(feature = "WKDownload", feature = "block2"))]
        #[optional]
        #[method(download:didReceiveAuthenticationChallenge:completionHandler:)]
        unsafe fn download_didReceiveAuthenticationChallenge_completionHandler(
            &self,
            download: &WKDownload,
            challenge: &NSURLAuthenticationChallenge,
            completion_handler: &block2::Block<
                dyn Fn(NSURLSessionAuthChallengeDisposition, *mut NSURLCredential),
            >,
        );

        #[cfg(feature = "WKDownload")]
        #[optional]
        #[method(downloadDidFinish:)]
        unsafe fn downloadDidFinish(&self, download: &WKDownload);

        #[cfg(feature = "WKDownload")]
        #[optional]
        #[method(download:didFailWithError:resumeData:)]
        unsafe fn download_didFailWithError_resumeData(
            &self,
            download: &WKDownload,
            error: &NSError,
            resume_data: Option<&NSData>,
        );
    }

    unsafe impl ProtocolType for dyn WKDownloadDelegate {}
);