icrate 0.0.1

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

extern_protocol!(
    pub struct NSURLProtocolClient;

    unsafe impl ProtocolType for NSURLProtocolClient {
        #[method(URLProtocol:wasRedirectedToRequest:redirectResponse:)]
        pub unsafe fn URLProtocol_wasRedirectedToRequest_redirectResponse(
            &self,
            protocol: &NSURLProtocol,
            request: &NSURLRequest,
            redirectResponse: &NSURLResponse,
        );

        #[method(URLProtocol:cachedResponseIsValid:)]
        pub unsafe fn URLProtocol_cachedResponseIsValid(
            &self,
            protocol: &NSURLProtocol,
            cachedResponse: &NSCachedURLResponse,
        );

        #[method(URLProtocol:didReceiveResponse:cacheStoragePolicy:)]
        pub unsafe fn URLProtocol_didReceiveResponse_cacheStoragePolicy(
            &self,
            protocol: &NSURLProtocol,
            response: &NSURLResponse,
            policy: NSURLCacheStoragePolicy,
        );

        #[method(URLProtocol:didLoadData:)]
        pub unsafe fn URLProtocol_didLoadData(&self, protocol: &NSURLProtocol, data: &NSData);

        #[method(URLProtocolDidFinishLoading:)]
        pub unsafe fn URLProtocolDidFinishLoading(&self, protocol: &NSURLProtocol);

        #[method(URLProtocol:didFailWithError:)]
        pub unsafe fn URLProtocol_didFailWithError(
            &self,
            protocol: &NSURLProtocol,
            error: &NSError,
        );

        #[method(URLProtocol:didReceiveAuthenticationChallenge:)]
        pub unsafe fn URLProtocol_didReceiveAuthenticationChallenge(
            &self,
            protocol: &NSURLProtocol,
            challenge: &NSURLAuthenticationChallenge,
        );

        #[method(URLProtocol:didCancelAuthenticationChallenge:)]
        pub unsafe fn URLProtocol_didCancelAuthenticationChallenge(
            &self,
            protocol: &NSURLProtocol,
            challenge: &NSURLAuthenticationChallenge,
        );
    }
);

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

    unsafe impl ClassType for NSURLProtocol {
        type Super = NSObject;
    }
);

extern_methods!(
    unsafe impl NSURLProtocol {
        #[method_id(@__retain_semantics Init initWithRequest:cachedResponse:client:)]
        pub unsafe fn initWithRequest_cachedResponse_client(
            this: Option<Allocated<Self>>,
            request: &NSURLRequest,
            cachedResponse: Option<&NSCachedURLResponse>,
            client: Option<&NSURLProtocolClient>,
        ) -> Id<Self, Shared>;

        #[method_id(@__retain_semantics Other client)]
        pub unsafe fn client(&self) -> Option<Id<NSURLProtocolClient, Shared>>;

        #[method_id(@__retain_semantics Other request)]
        pub unsafe fn request(&self) -> Id<NSURLRequest, Shared>;

        #[method_id(@__retain_semantics Other cachedResponse)]
        pub unsafe fn cachedResponse(&self) -> Option<Id<NSCachedURLResponse, Shared>>;

        #[method(canInitWithRequest:)]
        pub unsafe fn canInitWithRequest(request: &NSURLRequest) -> bool;

        #[method_id(@__retain_semantics Other canonicalRequestForRequest:)]
        pub unsafe fn canonicalRequestForRequest(
            request: &NSURLRequest,
        ) -> Id<NSURLRequest, Shared>;

        #[method(requestIsCacheEquivalent:toRequest:)]
        pub unsafe fn requestIsCacheEquivalent_toRequest(
            a: &NSURLRequest,
            b: &NSURLRequest,
        ) -> bool;

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

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

        #[method_id(@__retain_semantics Other propertyForKey:inRequest:)]
        pub unsafe fn propertyForKey_inRequest(
            key: &NSString,
            request: &NSURLRequest,
        ) -> Option<Id<Object, Shared>>;

        #[method(setProperty:forKey:inRequest:)]
        pub unsafe fn setProperty_forKey_inRequest(
            value: &Object,
            key: &NSString,
            request: &NSMutableURLRequest,
        );

        #[method(removePropertyForKey:inRequest:)]
        pub unsafe fn removePropertyForKey_inRequest(key: &NSString, request: &NSMutableURLRequest);

        #[method(registerClass:)]
        pub unsafe fn registerClass(protocolClass: &Class) -> bool;

        #[method(unregisterClass:)]
        pub unsafe fn unregisterClass(protocolClass: &Class);
    }
);

extern_methods!(
    /// NSURLSessionTaskAdditions
    unsafe impl NSURLProtocol {
        #[method(canInitWithTask:)]
        pub unsafe fn canInitWithTask(task: &NSURLSessionTask) -> bool;

        #[method_id(@__retain_semantics Init initWithTask:cachedResponse:client:)]
        pub unsafe fn initWithTask_cachedResponse_client(
            this: Option<Allocated<Self>>,
            task: &NSURLSessionTask,
            cachedResponse: Option<&NSCachedURLResponse>,
            client: Option<&NSURLProtocolClient>,
        ) -> Id<Self, Shared>;

        #[method_id(@__retain_semantics Other task)]
        pub unsafe fn task(&self) -> Option<Id<NSURLSessionTask, Shared>>;
    }
);