objc2_foundation/generated/
NSTextCheckingResult.rs1use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5
6use crate::*;
7
8#[repr(transparent)]
11#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
12pub struct NSTextCheckingType(pub u64);
13bitflags::bitflags! {
14 impl NSTextCheckingType: u64 {
15 #[doc(alias = "NSTextCheckingTypeOrthography")]
16 const Orthography = 1<<0;
17 #[doc(alias = "NSTextCheckingTypeSpelling")]
18 const Spelling = 1<<1;
19 #[doc(alias = "NSTextCheckingTypeGrammar")]
20 const Grammar = 1<<2;
21 #[doc(alias = "NSTextCheckingTypeDate")]
22 const Date = 1<<3;
23 #[doc(alias = "NSTextCheckingTypeAddress")]
24 const Address = 1<<4;
25 #[doc(alias = "NSTextCheckingTypeLink")]
26 const Link = 1<<5;
27 #[doc(alias = "NSTextCheckingTypeQuote")]
28 const Quote = 1<<6;
29 #[doc(alias = "NSTextCheckingTypeDash")]
30 const Dash = 1<<7;
31 #[doc(alias = "NSTextCheckingTypeReplacement")]
32 const Replacement = 1<<8;
33 #[doc(alias = "NSTextCheckingTypeCorrection")]
34 const Correction = 1<<9;
35 #[doc(alias = "NSTextCheckingTypeRegularExpression")]
36 const RegularExpression = 1<<10;
37 #[doc(alias = "NSTextCheckingTypePhoneNumber")]
38 const PhoneNumber = 1<<11;
39 #[doc(alias = "NSTextCheckingTypeTransitInformation")]
40 const TransitInformation = 1<<12;
41 }
42}
43
44unsafe impl Encode for NSTextCheckingType {
45 const ENCODING: Encoding = u64::ENCODING;
46}
47
48unsafe impl RefEncode for NSTextCheckingType {
49 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
50}
51
52pub type NSTextCheckingTypes = u64;
54
55pub const NSTextCheckingAllSystemTypes: NSTextCheckingTypes = 0xffffffff;
57pub const NSTextCheckingAllCustomTypes: NSTextCheckingTypes = 0xffffffff << 32;
59pub const NSTextCheckingAllTypes: NSTextCheckingTypes =
61 NSTextCheckingAllSystemTypes | NSTextCheckingAllCustomTypes;
62
63#[cfg(feature = "NSString")]
66pub type NSTextCheckingKey = NSString;
67
68extern_class!(
69 #[unsafe(super(NSObject))]
71 #[derive(Debug, PartialEq, Eq, Hash)]
72 pub struct NSTextCheckingResult;
73);
74
75#[cfg(feature = "NSObject")]
76extern_conformance!(
77 unsafe impl NSCoding for NSTextCheckingResult {}
78);
79
80#[cfg(feature = "NSObject")]
81extern_conformance!(
82 unsafe impl NSCopying for NSTextCheckingResult {}
83);
84
85#[cfg(feature = "NSObject")]
86unsafe impl CopyingHelper for NSTextCheckingResult {
87 type Result = Self;
88}
89
90extern_conformance!(
91 unsafe impl NSObjectProtocol for NSTextCheckingResult {}
92);
93
94#[cfg(feature = "NSObject")]
95extern_conformance!(
96 unsafe impl NSSecureCoding for NSTextCheckingResult {}
97);
98
99impl NSTextCheckingResult {
100 extern_methods!(
101 #[unsafe(method(resultType))]
102 #[unsafe(method_family = none)]
103 pub fn resultType(&self) -> NSTextCheckingType;
104
105 #[cfg(feature = "NSRange")]
106 #[unsafe(method(range))]
107 #[unsafe(method_family = none)]
108 pub fn range(&self) -> NSRange;
109 );
110}
111
112impl NSTextCheckingResult {
114 extern_methods!(
115 #[unsafe(method(init))]
116 #[unsafe(method_family = init)]
117 pub fn init(this: Allocated<Self>) -> Retained<Self>;
118
119 #[unsafe(method(new))]
120 #[unsafe(method_family = new)]
121 pub fn new() -> Retained<Self>;
122 );
123}
124
125impl DefaultRetained for NSTextCheckingResult {
126 #[inline]
127 fn default_retained() -> Retained<Self> {
128 Self::new()
129 }
130}
131
132impl NSTextCheckingResult {
134 extern_methods!(
135 #[cfg(feature = "NSOrthography")]
136 #[unsafe(method(orthography))]
137 #[unsafe(method_family = none)]
138 pub fn orthography(&self) -> Option<Retained<NSOrthography>>;
139
140 #[cfg(all(feature = "NSArray", feature = "NSDictionary", feature = "NSString"))]
141 #[unsafe(method(grammarDetails))]
142 #[unsafe(method_family = none)]
143 pub fn grammarDetails(
144 &self,
145 ) -> Option<Retained<NSArray<NSDictionary<NSString, AnyObject>>>>;
146
147 #[cfg(feature = "NSDate")]
148 #[unsafe(method(date))]
149 #[unsafe(method_family = none)]
150 pub fn date(&self) -> Option<Retained<NSDate>>;
151
152 #[cfg(feature = "NSTimeZone")]
153 #[unsafe(method(timeZone))]
154 #[unsafe(method_family = none)]
155 pub fn timeZone(&self) -> Option<Retained<NSTimeZone>>;
156
157 #[cfg(feature = "NSDate")]
158 #[unsafe(method(duration))]
159 #[unsafe(method_family = none)]
160 pub fn duration(&self) -> NSTimeInterval;
161
162 #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
163 #[unsafe(method(components))]
164 #[unsafe(method_family = none)]
165 pub fn components(&self) -> Option<Retained<NSDictionary<NSTextCheckingKey, NSString>>>;
166
167 #[cfg(feature = "NSURL")]
168 #[unsafe(method(URL))]
169 #[unsafe(method_family = none)]
170 pub fn URL(&self) -> Option<Retained<NSURL>>;
171
172 #[cfg(feature = "NSString")]
173 #[unsafe(method(replacementString))]
174 #[unsafe(method_family = none)]
175 pub fn replacementString(&self) -> Option<Retained<NSString>>;
176
177 #[cfg(all(feature = "NSArray", feature = "NSString"))]
178 #[unsafe(method(alternativeStrings))]
179 #[unsafe(method_family = none)]
180 pub fn alternativeStrings(&self) -> Option<Retained<NSArray<NSString>>>;
181
182 #[cfg(feature = "NSRegularExpression")]
183 #[unsafe(method(regularExpression))]
184 #[unsafe(method_family = none)]
185 pub fn regularExpression(&self) -> Option<Retained<NSRegularExpression>>;
186
187 #[cfg(feature = "NSString")]
188 #[unsafe(method(phoneNumber))]
189 #[unsafe(method_family = none)]
190 pub fn phoneNumber(&self) -> Option<Retained<NSString>>;
191
192 #[unsafe(method(numberOfRanges))]
193 #[unsafe(method_family = none)]
194 pub fn numberOfRanges(&self) -> NSUInteger;
195
196 #[cfg(feature = "NSRange")]
197 #[unsafe(method(rangeAtIndex:))]
198 #[unsafe(method_family = none)]
199 pub fn rangeAtIndex(&self, idx: NSUInteger) -> NSRange;
200
201 #[cfg(all(feature = "NSRange", feature = "NSString"))]
202 #[unsafe(method(rangeWithName:))]
203 #[unsafe(method_family = none)]
204 pub fn rangeWithName(&self, name: &NSString) -> NSRange;
205
206 #[unsafe(method(resultByAdjustingRangesWithOffset:))]
207 #[unsafe(method_family = none)]
208 pub fn resultByAdjustingRangesWithOffset(
209 &self,
210 offset: NSInteger,
211 ) -> Retained<NSTextCheckingResult>;
212
213 #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
214 #[unsafe(method(addressComponents))]
215 #[unsafe(method_family = none)]
216 pub fn addressComponents(
217 &self,
218 ) -> Option<Retained<NSDictionary<NSTextCheckingKey, NSString>>>;
219 );
220}
221
222extern "C" {
223 #[cfg(feature = "NSString")]
225 pub static NSTextCheckingNameKey: &'static NSTextCheckingKey;
226}
227
228extern "C" {
229 #[cfg(feature = "NSString")]
231 pub static NSTextCheckingJobTitleKey: &'static NSTextCheckingKey;
232}
233
234extern "C" {
235 #[cfg(feature = "NSString")]
237 pub static NSTextCheckingOrganizationKey: &'static NSTextCheckingKey;
238}
239
240extern "C" {
241 #[cfg(feature = "NSString")]
243 pub static NSTextCheckingStreetKey: &'static NSTextCheckingKey;
244}
245
246extern "C" {
247 #[cfg(feature = "NSString")]
249 pub static NSTextCheckingCityKey: &'static NSTextCheckingKey;
250}
251
252extern "C" {
253 #[cfg(feature = "NSString")]
255 pub static NSTextCheckingStateKey: &'static NSTextCheckingKey;
256}
257
258extern "C" {
259 #[cfg(feature = "NSString")]
261 pub static NSTextCheckingZIPKey: &'static NSTextCheckingKey;
262}
263
264extern "C" {
265 #[cfg(feature = "NSString")]
267 pub static NSTextCheckingCountryKey: &'static NSTextCheckingKey;
268}
269
270extern "C" {
271 #[cfg(feature = "NSString")]
273 pub static NSTextCheckingPhoneKey: &'static NSTextCheckingKey;
274}
275
276extern "C" {
277 #[cfg(feature = "NSString")]
279 pub static NSTextCheckingAirlineKey: &'static NSTextCheckingKey;
280}
281
282extern "C" {
283 #[cfg(feature = "NSString")]
285 pub static NSTextCheckingFlightKey: &'static NSTextCheckingKey;
286}
287
288impl NSTextCheckingResult {
290 extern_methods!(
291 #[cfg(all(feature = "NSOrthography", feature = "NSRange"))]
292 #[unsafe(method(orthographyCheckingResultWithRange:orthography:))]
293 #[unsafe(method_family = none)]
294 pub fn orthographyCheckingResultWithRange_orthography(
295 range: NSRange,
296 orthography: &NSOrthography,
297 ) -> Retained<NSTextCheckingResult>;
298
299 #[cfg(feature = "NSRange")]
300 #[unsafe(method(spellCheckingResultWithRange:))]
301 #[unsafe(method_family = none)]
302 pub fn spellCheckingResultWithRange(range: NSRange) -> Retained<NSTextCheckingResult>;
303
304 #[cfg(all(
305 feature = "NSArray",
306 feature = "NSDictionary",
307 feature = "NSRange",
308 feature = "NSString"
309 ))]
310 #[unsafe(method(grammarCheckingResultWithRange:details:))]
314 #[unsafe(method_family = none)]
315 pub unsafe fn grammarCheckingResultWithRange_details(
316 range: NSRange,
317 details: &NSArray<NSDictionary<NSString, AnyObject>>,
318 ) -> Retained<NSTextCheckingResult>;
319
320 #[cfg(all(feature = "NSDate", feature = "NSRange"))]
321 #[unsafe(method(dateCheckingResultWithRange:date:))]
322 #[unsafe(method_family = none)]
323 pub fn dateCheckingResultWithRange_date(
324 range: NSRange,
325 date: &NSDate,
326 ) -> Retained<NSTextCheckingResult>;
327
328 #[cfg(all(feature = "NSDate", feature = "NSRange", feature = "NSTimeZone"))]
329 #[unsafe(method(dateCheckingResultWithRange:date:timeZone:duration:))]
330 #[unsafe(method_family = none)]
331 pub fn dateCheckingResultWithRange_date_timeZone_duration(
332 range: NSRange,
333 date: &NSDate,
334 time_zone: &NSTimeZone,
335 duration: NSTimeInterval,
336 ) -> Retained<NSTextCheckingResult>;
337
338 #[cfg(all(feature = "NSDictionary", feature = "NSRange", feature = "NSString"))]
339 #[unsafe(method(addressCheckingResultWithRange:components:))]
340 #[unsafe(method_family = none)]
341 pub fn addressCheckingResultWithRange_components(
342 range: NSRange,
343 components: &NSDictionary<NSTextCheckingKey, NSString>,
344 ) -> Retained<NSTextCheckingResult>;
345
346 #[cfg(all(feature = "NSRange", feature = "NSURL"))]
347 #[unsafe(method(linkCheckingResultWithRange:URL:))]
348 #[unsafe(method_family = none)]
349 pub fn linkCheckingResultWithRange_URL(
350 range: NSRange,
351 url: &NSURL,
352 ) -> Retained<NSTextCheckingResult>;
353
354 #[cfg(all(feature = "NSRange", feature = "NSString"))]
355 #[unsafe(method(quoteCheckingResultWithRange:replacementString:))]
356 #[unsafe(method_family = none)]
357 pub fn quoteCheckingResultWithRange_replacementString(
358 range: NSRange,
359 replacement_string: &NSString,
360 ) -> Retained<NSTextCheckingResult>;
361
362 #[cfg(all(feature = "NSRange", feature = "NSString"))]
363 #[unsafe(method(dashCheckingResultWithRange:replacementString:))]
364 #[unsafe(method_family = none)]
365 pub fn dashCheckingResultWithRange_replacementString(
366 range: NSRange,
367 replacement_string: &NSString,
368 ) -> Retained<NSTextCheckingResult>;
369
370 #[cfg(all(feature = "NSRange", feature = "NSString"))]
371 #[unsafe(method(replacementCheckingResultWithRange:replacementString:))]
372 #[unsafe(method_family = none)]
373 pub fn replacementCheckingResultWithRange_replacementString(
374 range: NSRange,
375 replacement_string: &NSString,
376 ) -> Retained<NSTextCheckingResult>;
377
378 #[cfg(all(feature = "NSRange", feature = "NSString"))]
379 #[unsafe(method(correctionCheckingResultWithRange:replacementString:))]
380 #[unsafe(method_family = none)]
381 pub fn correctionCheckingResultWithRange_replacementString(
382 range: NSRange,
383 replacement_string: &NSString,
384 ) -> Retained<NSTextCheckingResult>;
385
386 #[cfg(all(feature = "NSArray", feature = "NSRange", feature = "NSString"))]
387 #[unsafe(method(correctionCheckingResultWithRange:replacementString:alternativeStrings:))]
388 #[unsafe(method_family = none)]
389 pub fn correctionCheckingResultWithRange_replacementString_alternativeStrings(
390 range: NSRange,
391 replacement_string: &NSString,
392 alternative_strings: &NSArray<NSString>,
393 ) -> Retained<NSTextCheckingResult>;
394
395 #[cfg(all(feature = "NSRange", feature = "NSRegularExpression"))]
396 #[unsafe(method(regularExpressionCheckingResultWithRanges:count:regularExpression:))]
400 #[unsafe(method_family = none)]
401 pub unsafe fn regularExpressionCheckingResultWithRanges_count_regularExpression(
402 ranges: NSRangePointer,
403 count: NSUInteger,
404 regular_expression: &NSRegularExpression,
405 ) -> Retained<NSTextCheckingResult>;
406
407 #[cfg(all(feature = "NSRange", feature = "NSString"))]
408 #[unsafe(method(phoneNumberCheckingResultWithRange:phoneNumber:))]
409 #[unsafe(method_family = none)]
410 pub fn phoneNumberCheckingResultWithRange_phoneNumber(
411 range: NSRange,
412 phone_number: &NSString,
413 ) -> Retained<NSTextCheckingResult>;
414
415 #[cfg(all(feature = "NSDictionary", feature = "NSRange", feature = "NSString"))]
416 #[unsafe(method(transitInformationCheckingResultWithRange:components:))]
417 #[unsafe(method_family = none)]
418 pub fn transitInformationCheckingResultWithRange_components(
419 range: NSRange,
420 components: &NSDictionary<NSTextCheckingKey, NSString>,
421 ) -> Retained<NSTextCheckingResult>;
422 );
423}