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

ns_enum!(
    #[underlying(NSUInteger)]
    pub enum NSURLCacheStoragePolicy {
        NSURLCacheStorageAllowed = 0,
        NSURLCacheStorageAllowedInMemoryOnly = 1,
        NSURLCacheStorageNotAllowed = 2,
    }
);

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

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

extern_methods!(
    unsafe impl NSCachedURLResponse {
        #[method_id(@__retain_semantics Init initWithResponse:data:)]
        pub unsafe fn initWithResponse_data(
            this: Option<Allocated<Self>>,
            response: &NSURLResponse,
            data: &NSData,
        ) -> Id<Self, Shared>;

        #[method_id(@__retain_semantics Init initWithResponse:data:userInfo:storagePolicy:)]
        pub unsafe fn initWithResponse_data_userInfo_storagePolicy(
            this: Option<Allocated<Self>>,
            response: &NSURLResponse,
            data: &NSData,
            userInfo: Option<&NSDictionary>,
            storagePolicy: NSURLCacheStoragePolicy,
        ) -> Id<Self, Shared>;

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

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

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

        #[method(storagePolicy)]
        pub unsafe fn storagePolicy(&self) -> NSURLCacheStoragePolicy;
    }
);

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

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

extern_methods!(
    unsafe impl NSURLCache {
        #[method_id(@__retain_semantics Other sharedURLCache)]
        pub unsafe fn sharedURLCache() -> Id<NSURLCache, Shared>;

        #[method(setSharedURLCache:)]
        pub unsafe fn setSharedURLCache(sharedURLCache: &NSURLCache);

        #[method_id(@__retain_semantics Init initWithMemoryCapacity:diskCapacity:diskPath:)]
        pub unsafe fn initWithMemoryCapacity_diskCapacity_diskPath(
            this: Option<Allocated<Self>>,
            memoryCapacity: NSUInteger,
            diskCapacity: NSUInteger,
            path: Option<&NSString>,
        ) -> Id<Self, Shared>;

        #[method_id(@__retain_semantics Init initWithMemoryCapacity:diskCapacity:directoryURL:)]
        pub unsafe fn initWithMemoryCapacity_diskCapacity_directoryURL(
            this: Option<Allocated<Self>>,
            memoryCapacity: NSUInteger,
            diskCapacity: NSUInteger,
            directoryURL: Option<&NSURL>,
        ) -> Id<Self, Shared>;

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

        #[method(storeCachedResponse:forRequest:)]
        pub unsafe fn storeCachedResponse_forRequest(
            &self,
            cachedResponse: &NSCachedURLResponse,
            request: &NSURLRequest,
        );

        #[method(removeCachedResponseForRequest:)]
        pub unsafe fn removeCachedResponseForRequest(&self, request: &NSURLRequest);

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

        #[method(removeCachedResponsesSinceDate:)]
        pub unsafe fn removeCachedResponsesSinceDate(&self, date: &NSDate);

        #[method(memoryCapacity)]
        pub unsafe fn memoryCapacity(&self) -> NSUInteger;

        #[method(setMemoryCapacity:)]
        pub unsafe fn setMemoryCapacity(&self, memoryCapacity: NSUInteger);

        #[method(diskCapacity)]
        pub unsafe fn diskCapacity(&self) -> NSUInteger;

        #[method(setDiskCapacity:)]
        pub unsafe fn setDiskCapacity(&self, diskCapacity: NSUInteger);

        #[method(currentMemoryUsage)]
        pub unsafe fn currentMemoryUsage(&self) -> NSUInteger;

        #[method(currentDiskUsage)]
        pub unsafe fn currentDiskUsage(&self) -> NSUInteger;
    }
);

extern_methods!(
    /// NSURLSessionTaskAdditions
    unsafe impl NSURLCache {
        #[method(storeCachedResponse:forDataTask:)]
        pub unsafe fn storeCachedResponse_forDataTask(
            &self,
            cachedResponse: &NSCachedURLResponse,
            dataTask: &NSURLSessionDataTask,
        );

        #[method(getCachedResponseForDataTask:completionHandler:)]
        pub unsafe fn getCachedResponseForDataTask_completionHandler(
            &self,
            dataTask: &NSURLSessionDataTask,
            completionHandler: &Block<(*mut NSCachedURLResponse,), ()>,
        );

        #[method(removeCachedResponseForDataTask:)]
        pub unsafe fn removeCachedResponseForDataTask(&self, dataTask: &NSURLSessionDataTask);
    }
);