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
22unsafe impl NSCoding for WKWebsiteDataStore {}
23
24unsafe impl NSObjectProtocol for WKWebsiteDataStore {}
25
26unsafe impl NSSecureCoding for WKWebsiteDataStore {}
27
28impl WKWebsiteDataStore {
29 extern_methods!(
30 #[unsafe(method(defaultDataStore))]
31 #[unsafe(method_family = none)]
32 pub unsafe fn defaultDataStore(mtm: MainThreadMarker) -> Retained<WKWebsiteDataStore>;
33
34 /// Returns a new non-persistent data store.
35 ///
36 /// If a WKWebView is associated with a non-persistent data store, no data will
37 /// be written to the file system. This is useful for implementing "private browsing" in a web view.
38 #[unsafe(method(nonPersistentDataStore))]
39 #[unsafe(method_family = none)]
40 pub unsafe fn nonPersistentDataStore(mtm: MainThreadMarker)
41 -> Retained<WKWebsiteDataStore>;
42
43 #[unsafe(method(new))]
44 #[unsafe(method_family = new)]
45 pub unsafe fn new(&self) -> Retained<Self>;
46
47 #[unsafe(method(init))]
48 #[unsafe(method_family = init)]
49 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
50
51 /// Whether the data store is persistent or not.
52 #[unsafe(method(isPersistent))]
53 #[unsafe(method_family = none)]
54 pub unsafe fn isPersistent(&self) -> bool;
55
56 /// Returns a set of all available website data types.
57 #[unsafe(method(allWebsiteDataTypes))]
58 #[unsafe(method_family = none)]
59 pub unsafe fn allWebsiteDataTypes(mtm: MainThreadMarker) -> Retained<NSSet<NSString>>;
60
61 #[cfg(all(feature = "WKWebsiteDataRecord", feature = "block2"))]
62 /// Fetches data records containing the given website data types.
63 ///
64 /// Parameter `dataTypes`: The website data types to fetch records for.
65 ///
66 /// Parameter `completionHandler`: A block to invoke when the data records have been fetched.
67 #[unsafe(method(fetchDataRecordsOfTypes:completionHandler:))]
68 #[unsafe(method_family = none)]
69 pub unsafe fn fetchDataRecordsOfTypes_completionHandler(
70 &self,
71 data_types: &NSSet<NSString>,
72 completion_handler: &block2::Block<dyn Fn(NonNull<NSArray<WKWebsiteDataRecord>>)>,
73 );
74
75 #[cfg(all(feature = "WKWebsiteDataRecord", feature = "block2"))]
76 /// Removes website data of the given types for the given data records.
77 ///
78 /// Parameter `dataTypes`: The website data types that should be removed.
79 ///
80 /// Parameter `dataRecords`: The website data records to delete website data for.
81 ///
82 /// Parameter `completionHandler`: A block to invoke when the website data for the records has been removed.
83 #[unsafe(method(removeDataOfTypes:forDataRecords:completionHandler:))]
84 #[unsafe(method_family = none)]
85 pub unsafe fn removeDataOfTypes_forDataRecords_completionHandler(
86 &self,
87 data_types: &NSSet<NSString>,
88 data_records: &NSArray<WKWebsiteDataRecord>,
89 completion_handler: &block2::Block<dyn Fn()>,
90 );
91
92 #[cfg(feature = "block2")]
93 /// Removes all website data of the given types that has been modified since the given date.
94 ///
95 /// Parameter `dataTypes`: The website data types that should be removed.
96 ///
97 /// Parameter `date`: A date. All website data modified after this date will be removed.
98 ///
99 /// Parameter `completionHandler`: A block to invoke when the website data has been removed.
100 #[unsafe(method(removeDataOfTypes:modifiedSince:completionHandler:))]
101 #[unsafe(method_family = none)]
102 pub unsafe fn removeDataOfTypes_modifiedSince_completionHandler(
103 &self,
104 data_types: &NSSet<NSString>,
105 date: &NSDate,
106 completion_handler: &block2::Block<dyn Fn()>,
107 );
108
109 #[cfg(feature = "WKHTTPCookieStore")]
110 /// Returns the cookie store representing HTTP cookies in this website data store.
111 #[unsafe(method(httpCookieStore))]
112 #[unsafe(method_family = none)]
113 pub unsafe fn httpCookieStore(&self) -> Retained<WKHTTPCookieStore>;
114
115 /// Get identifier for a data store.
116 ///
117 /// Returns nil for default and non-persistent data store .
118 #[unsafe(method(identifier))]
119 #[unsafe(method_family = none)]
120 pub unsafe fn identifier(&self) -> Option<Retained<NSUUID>>;
121
122 /// Get a persistent data store.
123 ///
124 /// Parameter `identifier`: An identifier that is used to uniquely identify the data store.
125 ///
126 /// If a data store with this identifier does not exist yet, it will be created. Throws exception if identifier
127 /// is 0.
128 #[unsafe(method(dataStoreForIdentifier:))]
129 #[unsafe(method_family = none)]
130 pub unsafe fn dataStoreForIdentifier(
131 identifier: &NSUUID,
132 mtm: MainThreadMarker,
133 ) -> Retained<WKWebsiteDataStore>;
134
135 #[cfg(feature = "block2")]
136 /// Delete a persistent data store.
137 ///
138 /// Parameter `identifier`: An identifier that is used to uniquely identify the data store.
139 ///
140 /// Parameter `completionHandler`: A block to invoke with optional error when the operation completes.
141 ///
142 /// This should be called when the data store is not used any more. Returns error if removal fails
143 /// to complete. WKWebView using the data store must be released before removal.
144 #[unsafe(method(removeDataStoreForIdentifier:completionHandler:))]
145 #[unsafe(method_family = none)]
146 pub unsafe fn removeDataStoreForIdentifier_completionHandler(
147 identifier: &NSUUID,
148 completion_handler: &block2::Block<dyn Fn(*mut NSError)>,
149 mtm: MainThreadMarker,
150 );
151
152 #[cfg(feature = "block2")]
153 /// Fetch all data stores identifiers.
154 ///
155 /// Parameter `completionHandler`: A block to invoke with an array of identifiers when the operation completes.
156 ///
157 /// Default or non-persistent data store do not have an identifier.
158 #[unsafe(method(fetchAllDataStoreIdentifiers:))]
159 #[unsafe(method_family = none)]
160 pub unsafe fn fetchAllDataStoreIdentifiers(
161 completion_handler: &block2::Block<dyn Fn(NonNull<NSArray<NSUUID>>)>,
162 mtm: MainThreadMarker,
163 );
164 );
165}
166
167/// Methods declared on superclass `NSObject`.
168impl WKWebsiteDataStore {
169 extern_methods!(
170 #[unsafe(method(new))]
171 #[unsafe(method_family = new)]
172 pub unsafe fn new_class(mtm: MainThreadMarker) -> Retained<Self>;
173 );
174}