objc2_web_kit/generated/
WKWebsiteDataStore.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_class!(
11    /// A WKWebsiteDataStore represents various types of data that a website might
12    /// make use of. This includes cookies, disk and memory caches, and persistent data such as WebSQL,
13    /// IndexedDB databases, and local storage.
14    ///
15    /// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkwebsitedatastore?language=objc)
16    #[unsafe(super(NSObject))]
17    #[thread_kind = MainThreadOnly]
18    #[derive(Debug, PartialEq, Eq, Hash)]
19    pub struct WKWebsiteDataStore;
20);
21
22extern_conformance!(
23    unsafe impl NSCoding for WKWebsiteDataStore {}
24);
25
26extern_conformance!(
27    unsafe impl NSObjectProtocol for WKWebsiteDataStore {}
28);
29
30extern_conformance!(
31    unsafe impl NSSecureCoding for WKWebsiteDataStore {}
32);
33
34impl WKWebsiteDataStore {
35    extern_methods!(
36        #[unsafe(method(defaultDataStore))]
37        #[unsafe(method_family = none)]
38        pub unsafe fn defaultDataStore(mtm: MainThreadMarker) -> Retained<WKWebsiteDataStore>;
39
40        /// Returns a new non-persistent data store.
41        ///
42        /// If a WKWebView is associated with a non-persistent data store, no data will
43        /// be written to the file system. This is useful for implementing "private browsing" in a web view.
44        #[unsafe(method(nonPersistentDataStore))]
45        #[unsafe(method_family = none)]
46        pub unsafe fn nonPersistentDataStore(mtm: MainThreadMarker)
47            -> Retained<WKWebsiteDataStore>;
48
49        #[unsafe(method(new))]
50        #[unsafe(method_family = new)]
51        pub unsafe fn new(&self) -> Retained<Self>;
52
53        #[unsafe(method(init))]
54        #[unsafe(method_family = init)]
55        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
56
57        /// Whether the data store is persistent or not.
58        #[unsafe(method(isPersistent))]
59        #[unsafe(method_family = none)]
60        pub unsafe fn isPersistent(&self) -> bool;
61
62        /// Returns a set of all available website data types.
63        #[unsafe(method(allWebsiteDataTypes))]
64        #[unsafe(method_family = none)]
65        pub unsafe fn allWebsiteDataTypes(mtm: MainThreadMarker) -> Retained<NSSet<NSString>>;
66
67        #[cfg(all(feature = "WKWebsiteDataRecord", feature = "block2"))]
68        /// Fetches data records containing the given website data types.
69        ///
70        /// Parameter `dataTypes`: The website data types to fetch records for.
71        ///
72        /// Parameter `completionHandler`: A block to invoke when the data records have been fetched.
73        #[unsafe(method(fetchDataRecordsOfTypes:completionHandler:))]
74        #[unsafe(method_family = none)]
75        pub unsafe fn fetchDataRecordsOfTypes_completionHandler(
76            &self,
77            data_types: &NSSet<NSString>,
78            completion_handler: &block2::DynBlock<dyn Fn(NonNull<NSArray<WKWebsiteDataRecord>>)>,
79        );
80
81        #[cfg(all(feature = "WKWebsiteDataRecord", feature = "block2"))]
82        /// Removes website data of the given types for the given data records.
83        ///
84        /// Parameter `dataTypes`: The website data types that should be removed.
85        ///
86        /// Parameter `dataRecords`: The website data records to delete website data for.
87        ///
88        /// Parameter `completionHandler`: A block to invoke when the website data for the records has been removed.
89        #[unsafe(method(removeDataOfTypes:forDataRecords:completionHandler:))]
90        #[unsafe(method_family = none)]
91        pub unsafe fn removeDataOfTypes_forDataRecords_completionHandler(
92            &self,
93            data_types: &NSSet<NSString>,
94            data_records: &NSArray<WKWebsiteDataRecord>,
95            completion_handler: &block2::DynBlock<dyn Fn()>,
96        );
97
98        #[cfg(feature = "block2")]
99        /// Removes all website data of the given types that has been modified since the given date.
100        ///
101        /// Parameter `dataTypes`: The website data types that should be removed.
102        ///
103        /// Parameter `date`: A date. All website data modified after this date will be removed.
104        ///
105        /// Parameter `completionHandler`: A block to invoke when the website data has been removed.
106        #[unsafe(method(removeDataOfTypes:modifiedSince:completionHandler:))]
107        #[unsafe(method_family = none)]
108        pub unsafe fn removeDataOfTypes_modifiedSince_completionHandler(
109            &self,
110            data_types: &NSSet<NSString>,
111            date: &NSDate,
112            completion_handler: &block2::DynBlock<dyn Fn()>,
113        );
114
115        #[cfg(feature = "WKHTTPCookieStore")]
116        /// Returns the cookie store representing HTTP cookies in this website data store.
117        #[unsafe(method(httpCookieStore))]
118        #[unsafe(method_family = none)]
119        pub unsafe fn httpCookieStore(&self) -> Retained<WKHTTPCookieStore>;
120
121        /// Get identifier for a data store.
122        ///
123        /// Returns nil for default and non-persistent data store .
124        #[unsafe(method(identifier))]
125        #[unsafe(method_family = none)]
126        pub unsafe fn identifier(&self) -> Option<Retained<NSUUID>>;
127
128        #[cfg(feature = "block2")]
129        #[unsafe(method(fetchDataOfTypes:completionHandler:))]
130        #[unsafe(method_family = none)]
131        pub unsafe fn fetchDataOfTypes_completionHandler(
132            &self,
133            data_types: &NSSet<NSString>,
134            completion_handler: &block2::DynBlock<dyn Fn(*mut NSData, *mut NSError)>,
135        );
136
137        #[cfg(feature = "block2")]
138        #[unsafe(method(restoreData:completionHandler:))]
139        #[unsafe(method_family = none)]
140        pub unsafe fn restoreData_completionHandler(
141            &self,
142            data: &NSData,
143            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
144        );
145
146        /// Get a persistent data store.
147        ///
148        /// Parameter `identifier`: An identifier that is used to uniquely identify the data store.
149        ///
150        /// If a data store with this identifier does not exist yet, it will be created. Throws exception if identifier
151        /// is 0.
152        #[unsafe(method(dataStoreForIdentifier:))]
153        #[unsafe(method_family = none)]
154        pub unsafe fn dataStoreForIdentifier(
155            identifier: &NSUUID,
156            mtm: MainThreadMarker,
157        ) -> Retained<WKWebsiteDataStore>;
158
159        #[cfg(feature = "block2")]
160        /// Delete a persistent data store.
161        ///
162        /// Parameter `identifier`: An identifier that is used to uniquely identify the data store.
163        ///
164        /// Parameter `completionHandler`: A block to invoke with optional error when the operation completes.
165        ///
166        /// This should be called when the data store is not used any more. Returns error if removal fails
167        /// to complete. WKWebView using the data store must be released before removal.
168        #[unsafe(method(removeDataStoreForIdentifier:completionHandler:))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn removeDataStoreForIdentifier_completionHandler(
171            identifier: &NSUUID,
172            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
173            mtm: MainThreadMarker,
174        );
175
176        #[cfg(feature = "block2")]
177        /// Fetch all data stores identifiers.
178        ///
179        /// Parameter `completionHandler`: A block to invoke with an array of identifiers when the operation completes.
180        ///
181        /// Default or non-persistent data store do not have an identifier.
182        #[unsafe(method(fetchAllDataStoreIdentifiers:))]
183        #[unsafe(method_family = none)]
184        pub unsafe fn fetchAllDataStoreIdentifiers(
185            completion_handler: &block2::DynBlock<dyn Fn(NonNull<NSArray<NSUUID>>)>,
186            mtm: MainThreadMarker,
187        );
188    );
189}
190
191/// Methods declared on superclass `NSObject`.
192impl WKWebsiteDataStore {
193    extern_methods!(
194        #[unsafe(method(new))]
195        #[unsafe(method_family = new)]
196        pub unsafe fn new_class(mtm: MainThreadMarker) -> Retained<Self>;
197    );
198}