1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;
use crate::*;
extern "C" {
/// Indicates a ``WKWebExtensionMatchPattern`` error.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkwebextensionmatchpatternerrordomain?language=objc)
pub static WKWebExtensionMatchPatternErrorDomain: &'static NSErrorDomain;
}
/// Constants used by ``NSError`` to indicate errors in the ``WKWebExtensionMatchPattern`` domain.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkwebextensionmatchpatternerror?language=objc)
// NS_ERROR_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct WKWebExtensionMatchPatternError(pub NSInteger);
impl WKWebExtensionMatchPatternError {
#[doc(alias = "WKWebExtensionMatchPatternErrorUnknown")]
pub const Unknown: Self = Self(1);
#[doc(alias = "WKWebExtensionMatchPatternErrorInvalidScheme")]
pub const InvalidScheme: Self = Self(2);
#[doc(alias = "WKWebExtensionMatchPatternErrorInvalidHost")]
pub const InvalidHost: Self = Self(3);
#[doc(alias = "WKWebExtensionMatchPatternErrorInvalidPath")]
pub const InvalidPath: Self = Self(4);
}
unsafe impl Encode for WKWebExtensionMatchPatternError {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for WKWebExtensionMatchPatternError {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
/// Constants used by ``WKWebExtensionMatchPattern`` to indicate matching options.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkwebextensionmatchpatternoptions?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct WKWebExtensionMatchPatternOptions(pub NSUInteger);
bitflags::bitflags! {
impl WKWebExtensionMatchPatternOptions: NSUInteger {
#[doc(alias = "WKWebExtensionMatchPatternOptionsNone")]
const None = 0;
#[doc(alias = "WKWebExtensionMatchPatternOptionsIgnoreSchemes")]
const IgnoreSchemes = 1<<0;
#[doc(alias = "WKWebExtensionMatchPatternOptionsIgnorePaths")]
const IgnorePaths = 1<<1;
#[doc(alias = "WKWebExtensionMatchPatternOptionsMatchBidirectionally")]
const MatchBidirectionally = 1<<2;
}
}
unsafe impl Encode for WKWebExtensionMatchPatternOptions {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for WKWebExtensionMatchPatternOptions {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
/// A ``WKWebExtensionMatchPattern`` object represents a way to specify groups of URLs.
///
/// All match patterns are specified as strings. Apart from the special `
/// <all
/// _urls>` pattern, match patterns
/// consist of three parts: scheme, host, and path.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkwebextensionmatchpattern?language=objc)
#[unsafe(super(NSObject))]
#[thread_kind = MainThreadOnly]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct WKWebExtensionMatchPattern;
);
extern_conformance!(
unsafe impl NSCoding for WKWebExtensionMatchPattern {}
);
extern_conformance!(
unsafe impl NSCopying for WKWebExtensionMatchPattern {}
);
unsafe impl CopyingHelper for WKWebExtensionMatchPattern {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for WKWebExtensionMatchPattern {}
);
extern_conformance!(
unsafe impl NSSecureCoding for WKWebExtensionMatchPattern {}
);
impl WKWebExtensionMatchPattern {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
/// Registers a custom URL scheme that can be used in match patterns.
///
/// This method should be used to register any custom URL schemes used by the app for the extension base URLs,
/// other than `webkit-extension`, or if extensions should have access to other supported URL schemes when using `
/// <all
/// _urls>`.
///
/// Parameter `urlScheme`: The custom URL scheme to register.
#[unsafe(method(registerCustomURLScheme:))]
#[unsafe(method_family = none)]
pub unsafe fn registerCustomURLScheme(url_scheme: &NSString, mtm: MainThreadMarker);
/// Returns a pattern object for `
/// <all
/// _urls>`.
#[unsafe(method(allURLsMatchPattern))]
#[unsafe(method_family = none)]
pub unsafe fn allURLsMatchPattern(mtm: MainThreadMarker) -> Retained<Self>;
/// Returns a pattern object that has `*` for scheme, host, and path.
#[unsafe(method(allHostsAndSchemesMatchPattern))]
#[unsafe(method_family = none)]
pub unsafe fn allHostsAndSchemesMatchPattern(mtm: MainThreadMarker) -> Retained<Self>;
/// Returns a pattern object for the specified pattern string.
///
/// Returns: Returns `nil` if the pattern string is invalid.
///
/// See also: initWithString:error:
#[unsafe(method(matchPatternWithString:))]
#[unsafe(method_family = none)]
pub unsafe fn matchPatternWithString(
string: &NSString,
mtm: MainThreadMarker,
) -> Option<Retained<Self>>;
/// Returns a pattern object for the specified scheme, host, and path strings.
///
/// Returns: A pattern object, or `nil` if any of the strings are invalid.
///
/// See also: initWithScheme:host:path:error:
#[unsafe(method(matchPatternWithScheme:host:path:))]
#[unsafe(method_family = none)]
pub unsafe fn matchPatternWithScheme_host_path(
scheme: &NSString,
host: &NSString,
path: &NSString,
mtm: MainThreadMarker,
) -> Option<Retained<Self>>;
/// Returns a pattern object for the specified pattern string.
///
/// Parameter `error`: Set to
/// `nil`or an error instance if an error occurred.
///
/// Returns: A pattern object, or `nil` if the pattern string is invalid and an error will be set.
///
/// See also: initWithString:
#[unsafe(method(initWithString:error:_))]
#[unsafe(method_family = init)]
pub unsafe fn initWithString_error(
this: Allocated<Self>,
string: &NSString,
) -> Result<Retained<Self>, Retained<NSError>>;
/// Returns a pattern object for the specified scheme, host, and path strings.
///
/// Parameter `error`: Set to
/// `nil`or an error instance if an error occurred.
///
/// Returns: A pattern object, or `nil` if any of the strings are invalid and an error will be set.
///
/// See also: initWithScheme:host:path:
#[unsafe(method(initWithScheme:host:path:error:_))]
#[unsafe(method_family = init)]
pub unsafe fn initWithScheme_host_path_error(
this: Allocated<Self>,
scheme: &NSString,
host: &NSString,
path: &NSString,
) -> Result<Retained<Self>, Retained<NSError>>;
/// The original pattern string.
#[unsafe(method(string))]
#[unsafe(method_family = none)]
pub unsafe fn string(&self) -> Retained<NSString>;
/// The scheme part of the pattern string, unless ``matchesAllURLs`` is `YES`.
#[unsafe(method(scheme))]
#[unsafe(method_family = none)]
pub unsafe fn scheme(&self) -> Option<Retained<NSString>>;
/// The host part of the pattern string, unless ``matchesAllURLs`` is `YES`.
#[unsafe(method(host))]
#[unsafe(method_family = none)]
pub unsafe fn host(&self) -> Option<Retained<NSString>>;
/// The path part of the pattern string, unless ``matchesAllURLs`` is `YES`.
#[unsafe(method(path))]
#[unsafe(method_family = none)]
pub unsafe fn path(&self) -> Option<Retained<NSString>>;
/// If the pattern is `
/// <all
/// _urls>`.
#[unsafe(method(matchesAllURLs))]
#[unsafe(method_family = none)]
pub unsafe fn matchesAllURLs(&self) -> bool;
/// If the pattern is `
/// <all
/// _urls>` or has `*` as the host.
#[unsafe(method(matchesAllHosts))]
#[unsafe(method_family = none)]
pub unsafe fn matchesAllHosts(&self) -> bool;
/// Matches the reciever pattern against the specified URL.
///
/// Parameter `url`: The URL to match the against the reciever pattern.
///
/// Returns: A Boolean value indicating if pattern matches the specified URL.
///
/// See also: matchesURL:options:
#[unsafe(method(matchesURL:))]
#[unsafe(method_family = none)]
pub unsafe fn matchesURL(&self, url: Option<&NSURL>) -> bool;
/// Matches the reciever pattern against the specified URL with options.
///
/// Parameter `url`: The URL to match the against the reciever pattern.
///
/// Parameter `options`: The options to use while matching.
///
/// Returns: A Boolean value indicating if pattern matches the specified URL.
///
/// See also: matchesURL:
#[unsafe(method(matchesURL:options:))]
#[unsafe(method_family = none)]
pub unsafe fn matchesURL_options(
&self,
url: Option<&NSURL>,
options: WKWebExtensionMatchPatternOptions,
) -> bool;
/// Matches the receiver pattern against the specified pattern.
///
/// Parameter `pattern`: The pattern to match against the receiver pattern.
///
/// Returns: A Boolean value indicating if receiver pattern matches the specified pattern.
///
/// See also: matchesPattern:options:
#[unsafe(method(matchesPattern:))]
#[unsafe(method_family = none)]
pub unsafe fn matchesPattern(&self, pattern: Option<&WKWebExtensionMatchPattern>) -> bool;
/// Matches the receiver pattern against the specified pattern with options.
///
/// Parameter `pattern`: The pattern to match against the receiver pattern.
///
/// Parameter `options`: The options to use while matching.
///
/// Returns: A Boolean value indicating if receiver pattern matches the specified pattern.
///
/// See also: matchesPattern:
#[unsafe(method(matchesPattern:options:))]
#[unsafe(method_family = none)]
pub unsafe fn matchesPattern_options(
&self,
pattern: Option<&WKWebExtensionMatchPattern>,
options: WKWebExtensionMatchPatternOptions,
) -> bool;
);
}