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 /// Get a persistent data store.
129 ///
130 /// Parameter `identifier`: An identifier that is used to uniquely identify the data store.
131 ///
132 /// If a data store with this identifier does not exist yet, it will be created. Throws exception if identifier
133 /// is 0.
134 #[unsafe(method(dataStoreForIdentifier:))]
135 #[unsafe(method_family = none)]
136 pub unsafe fn dataStoreForIdentifier(
137 identifier: &NSUUID,
138 mtm: MainThreadMarker,
139 ) -> Retained<WKWebsiteDataStore>;
140
141 #[cfg(feature = "block2")]
142 /// Delete a persistent data store.
143 ///
144 /// Parameter `identifier`: An identifier that is used to uniquely identify the data store.
145 ///
146 /// Parameter `completionHandler`: A block to invoke with optional error when the operation completes.
147 ///
148 /// This should be called when the data store is not used any more. Returns error if removal fails
149 /// to complete. WKWebView using the data store must be released before removal.
150 #[unsafe(method(removeDataStoreForIdentifier:completionHandler:))]
151 #[unsafe(method_family = none)]
152 pub unsafe fn removeDataStoreForIdentifier_completionHandler(
153 identifier: &NSUUID,
154 completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
155 mtm: MainThreadMarker,
156 );
157
158 #[cfg(feature = "block2")]
159 /// Fetch all data stores identifiers.
160 ///
161 /// Parameter `completionHandler`: A block to invoke with an array of identifiers when the operation completes.
162 ///
163 /// Default or non-persistent data store do not have an identifier.
164 #[unsafe(method(fetchAllDataStoreIdentifiers:))]
165 #[unsafe(method_family = none)]
166 pub unsafe fn fetchAllDataStoreIdentifiers(
167 completion_handler: &block2::DynBlock<dyn Fn(NonNull<NSArray<NSUUID>>)>,
168 mtm: MainThreadMarker,
169 );
170 );
171}
172
173/// Methods declared on superclass `NSObject`.
174impl WKWebsiteDataStore {
175 extern_methods!(
176 #[unsafe(method(new))]
177 #[unsafe(method_family = new)]
178 pub unsafe fn new_class(mtm: MainThreadMarker) -> Retained<Self>;
179 );
180}