objc2_core_location/generated/
CLLocationManager.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
10/// [Apple's documentation](https://developer.apple.com/documentation/corelocation/cldeviceorientation?language=objc)
11// NS_ENUM
12#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct CLDeviceOrientation(pub c_int);
15impl CLDeviceOrientation {
16    #[doc(alias = "CLDeviceOrientationUnknown")]
17    pub const Unknown: Self = Self(0);
18    #[doc(alias = "CLDeviceOrientationPortrait")]
19    pub const Portrait: Self = Self(1);
20    #[doc(alias = "CLDeviceOrientationPortraitUpsideDown")]
21    pub const PortraitUpsideDown: Self = Self(2);
22    #[doc(alias = "CLDeviceOrientationLandscapeLeft")]
23    pub const LandscapeLeft: Self = Self(3);
24    #[doc(alias = "CLDeviceOrientationLandscapeRight")]
25    pub const LandscapeRight: Self = Self(4);
26    #[doc(alias = "CLDeviceOrientationFaceUp")]
27    pub const FaceUp: Self = Self(5);
28    #[doc(alias = "CLDeviceOrientationFaceDown")]
29    pub const FaceDown: Self = Self(6);
30}
31
32unsafe impl Encode for CLDeviceOrientation {
33    const ENCODING: Encoding = c_int::ENCODING;
34}
35
36unsafe impl RefEncode for CLDeviceOrientation {
37    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
38}
39
40/// [Apple's documentation](https://developer.apple.com/documentation/corelocation/clauthorizationstatus?language=objc)
41// NS_ENUM
42#[repr(transparent)]
43#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
44pub struct CLAuthorizationStatus(pub c_int);
45impl CLAuthorizationStatus {
46    #[doc(alias = "kCLAuthorizationStatusNotDetermined")]
47    pub const NotDetermined: Self = Self(0);
48    #[doc(alias = "kCLAuthorizationStatusRestricted")]
49    pub const Restricted: Self = Self(1);
50    #[doc(alias = "kCLAuthorizationStatusDenied")]
51    pub const Denied: Self = Self(2);
52    #[doc(alias = "kCLAuthorizationStatusAuthorizedAlways")]
53    pub const AuthorizedAlways: Self = Self(3);
54    #[doc(alias = "kCLAuthorizationStatusAuthorizedWhenInUse")]
55    pub const AuthorizedWhenInUse: Self = Self(4);
56    #[doc(alias = "kCLAuthorizationStatusAuthorized")]
57    #[deprecated = "Use kCLAuthorizationStatusAuthorizedAlways"]
58    pub const Authorized: Self = Self(CLAuthorizationStatus::AuthorizedAlways.0);
59}
60
61unsafe impl Encode for CLAuthorizationStatus {
62    const ENCODING: Encoding = c_int::ENCODING;
63}
64
65unsafe impl RefEncode for CLAuthorizationStatus {
66    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
67}
68
69/// [Apple's documentation](https://developer.apple.com/documentation/corelocation/claccuracyauthorization?language=objc)
70// NS_ENUM
71#[repr(transparent)]
72#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
73pub struct CLAccuracyAuthorization(pub NSInteger);
74impl CLAccuracyAuthorization {
75    #[doc(alias = "CLAccuracyAuthorizationFullAccuracy")]
76    pub const FullAccuracy: Self = Self(0);
77    #[doc(alias = "CLAccuracyAuthorizationReducedAccuracy")]
78    pub const ReducedAccuracy: Self = Self(1);
79}
80
81unsafe impl Encode for CLAccuracyAuthorization {
82    const ENCODING: Encoding = NSInteger::ENCODING;
83}
84
85unsafe impl RefEncode for CLAccuracyAuthorization {
86    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
87}
88
89/// [Apple's documentation](https://developer.apple.com/documentation/corelocation/clactivitytype?language=objc)
90// NS_ENUM
91#[repr(transparent)]
92#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
93pub struct CLActivityType(pub NSInteger);
94impl CLActivityType {
95    #[doc(alias = "CLActivityTypeOther")]
96    pub const Other: Self = Self(1);
97    #[doc(alias = "CLActivityTypeAutomotiveNavigation")]
98    pub const AutomotiveNavigation: Self = Self(2);
99    #[doc(alias = "CLActivityTypeFitness")]
100    pub const Fitness: Self = Self(3);
101    #[doc(alias = "CLActivityTypeOtherNavigation")]
102    pub const OtherNavigation: Self = Self(4);
103    #[doc(alias = "CLActivityTypeAirborne")]
104    pub const Airborne: Self = Self(5);
105}
106
107unsafe impl Encode for CLActivityType {
108    const ENCODING: Encoding = NSInteger::ENCODING;
109}
110
111unsafe impl RefEncode for CLActivityType {
112    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
113}
114
115extern_class!(
116    /// [Apple's documentation](https://developer.apple.com/documentation/corelocation/cllocationmanager?language=objc)
117    #[unsafe(super(NSObject))]
118    #[derive(Debug, PartialEq, Eq, Hash)]
119    pub struct CLLocationManager;
120);
121
122extern_conformance!(
123    unsafe impl NSObjectProtocol for CLLocationManager {}
124);
125
126impl CLLocationManager {
127    extern_methods!(
128        #[unsafe(method(locationServicesEnabled))]
129        #[unsafe(method_family = none)]
130        pub unsafe fn locationServicesEnabled_class() -> bool;
131
132        #[unsafe(method(headingAvailable))]
133        #[unsafe(method_family = none)]
134        pub unsafe fn headingAvailable_class() -> bool;
135
136        #[unsafe(method(significantLocationChangeMonitoringAvailable))]
137        #[unsafe(method_family = none)]
138        pub unsafe fn significantLocationChangeMonitoringAvailable() -> bool;
139
140        /// # Safety
141        ///
142        /// `region_class` probably has further requirements.
143        #[unsafe(method(isMonitoringAvailableForClass:))]
144        #[unsafe(method_family = none)]
145        pub unsafe fn isMonitoringAvailableForClass(region_class: &AnyClass) -> bool;
146
147        #[deprecated]
148        #[unsafe(method(regionMonitoringAvailable))]
149        #[unsafe(method_family = none)]
150        pub unsafe fn regionMonitoringAvailable() -> bool;
151
152        #[deprecated = "Use +isMonitoringAvailableForClass: and -authorizationStatus instead"]
153        #[unsafe(method(regionMonitoringEnabled))]
154        #[unsafe(method_family = none)]
155        pub unsafe fn regionMonitoringEnabled() -> bool;
156
157        #[unsafe(method(isRangingAvailable))]
158        #[unsafe(method_family = none)]
159        pub unsafe fn isRangingAvailable() -> bool;
160
161        #[unsafe(method(authorizationStatus))]
162        #[unsafe(method_family = none)]
163        pub unsafe fn authorizationStatus(&self) -> CLAuthorizationStatus;
164
165        #[deprecated]
166        #[unsafe(method(authorizationStatus))]
167        #[unsafe(method_family = none)]
168        pub unsafe fn authorizationStatus_class() -> CLAuthorizationStatus;
169
170        #[unsafe(method(accuracyAuthorization))]
171        #[unsafe(method_family = none)]
172        pub unsafe fn accuracyAuthorization(&self) -> CLAccuracyAuthorization;
173
174        #[unsafe(method(isAuthorizedForWidgetUpdates))]
175        #[unsafe(method_family = none)]
176        pub unsafe fn isAuthorizedForWidgetUpdates(&self) -> bool;
177
178        #[cfg(feature = "CLLocationManagerDelegate")]
179        #[unsafe(method(delegate))]
180        #[unsafe(method_family = none)]
181        pub unsafe fn delegate(
182            &self,
183        ) -> Option<Retained<ProtocolObject<dyn CLLocationManagerDelegate>>>;
184
185        #[cfg(feature = "CLLocationManagerDelegate")]
186        /// Setter for [`delegate`][Self::delegate].
187        ///
188        /// This is a [weak property][objc2::topics::weak_property].
189        #[unsafe(method(setDelegate:))]
190        #[unsafe(method_family = none)]
191        pub unsafe fn setDelegate(
192            &self,
193            delegate: Option<&ProtocolObject<dyn CLLocationManagerDelegate>>,
194        );
195
196        #[deprecated]
197        #[unsafe(method(locationServicesEnabled))]
198        #[unsafe(method_family = none)]
199        pub unsafe fn locationServicesEnabled(&self) -> bool;
200
201        #[deprecated = "Set the purpose string in Info.plist using key NSLocationUsageDescription"]
202        #[unsafe(method(purpose))]
203        #[unsafe(method_family = none)]
204        pub unsafe fn purpose(&self) -> Option<Retained<NSString>>;
205
206        /// Setter for [`purpose`][Self::purpose].
207        ///
208        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
209        #[deprecated = "Set the purpose string in Info.plist using key NSLocationUsageDescription"]
210        #[unsafe(method(setPurpose:))]
211        #[unsafe(method_family = none)]
212        pub unsafe fn setPurpose(&self, purpose: Option<&NSString>);
213
214        #[unsafe(method(activityType))]
215        #[unsafe(method_family = none)]
216        pub unsafe fn activityType(&self) -> CLActivityType;
217
218        /// Setter for [`activityType`][Self::activityType].
219        #[unsafe(method(setActivityType:))]
220        #[unsafe(method_family = none)]
221        pub unsafe fn setActivityType(&self, activity_type: CLActivityType);
222
223        #[cfg(feature = "CLLocation")]
224        #[unsafe(method(distanceFilter))]
225        #[unsafe(method_family = none)]
226        pub unsafe fn distanceFilter(&self) -> CLLocationDistance;
227
228        #[cfg(feature = "CLLocation")]
229        /// Setter for [`distanceFilter`][Self::distanceFilter].
230        #[unsafe(method(setDistanceFilter:))]
231        #[unsafe(method_family = none)]
232        pub unsafe fn setDistanceFilter(&self, distance_filter: CLLocationDistance);
233
234        #[cfg(feature = "CLLocation")]
235        #[unsafe(method(desiredAccuracy))]
236        #[unsafe(method_family = none)]
237        pub unsafe fn desiredAccuracy(&self) -> CLLocationAccuracy;
238
239        #[cfg(feature = "CLLocation")]
240        /// Setter for [`desiredAccuracy`][Self::desiredAccuracy].
241        #[unsafe(method(setDesiredAccuracy:))]
242        #[unsafe(method_family = none)]
243        pub unsafe fn setDesiredAccuracy(&self, desired_accuracy: CLLocationAccuracy);
244
245        #[unsafe(method(pausesLocationUpdatesAutomatically))]
246        #[unsafe(method_family = none)]
247        pub unsafe fn pausesLocationUpdatesAutomatically(&self) -> bool;
248
249        /// Setter for [`pausesLocationUpdatesAutomatically`][Self::pausesLocationUpdatesAutomatically].
250        #[unsafe(method(setPausesLocationUpdatesAutomatically:))]
251        #[unsafe(method_family = none)]
252        pub unsafe fn setPausesLocationUpdatesAutomatically(
253            &self,
254            pauses_location_updates_automatically: bool,
255        );
256
257        #[unsafe(method(allowsBackgroundLocationUpdates))]
258        #[unsafe(method_family = none)]
259        pub unsafe fn allowsBackgroundLocationUpdates(&self) -> bool;
260
261        /// Setter for [`allowsBackgroundLocationUpdates`][Self::allowsBackgroundLocationUpdates].
262        #[unsafe(method(setAllowsBackgroundLocationUpdates:))]
263        #[unsafe(method_family = none)]
264        pub unsafe fn setAllowsBackgroundLocationUpdates(
265            &self,
266            allows_background_location_updates: bool,
267        );
268
269        #[unsafe(method(showsBackgroundLocationIndicator))]
270        #[unsafe(method_family = none)]
271        pub unsafe fn showsBackgroundLocationIndicator(&self) -> bool;
272
273        /// Setter for [`showsBackgroundLocationIndicator`][Self::showsBackgroundLocationIndicator].
274        #[unsafe(method(setShowsBackgroundLocationIndicator:))]
275        #[unsafe(method_family = none)]
276        pub unsafe fn setShowsBackgroundLocationIndicator(
277            &self,
278            shows_background_location_indicator: bool,
279        );
280
281        #[cfg(feature = "CLLocation")]
282        #[unsafe(method(location))]
283        #[unsafe(method_family = none)]
284        pub unsafe fn location(&self) -> Option<Retained<CLLocation>>;
285
286        #[deprecated]
287        #[unsafe(method(headingAvailable))]
288        #[unsafe(method_family = none)]
289        pub unsafe fn headingAvailable(&self) -> bool;
290
291        #[cfg(feature = "CLLocation")]
292        #[unsafe(method(headingFilter))]
293        #[unsafe(method_family = none)]
294        pub unsafe fn headingFilter(&self) -> CLLocationDegrees;
295
296        #[cfg(feature = "CLLocation")]
297        /// Setter for [`headingFilter`][Self::headingFilter].
298        #[unsafe(method(setHeadingFilter:))]
299        #[unsafe(method_family = none)]
300        pub unsafe fn setHeadingFilter(&self, heading_filter: CLLocationDegrees);
301
302        #[unsafe(method(headingOrientation))]
303        #[unsafe(method_family = none)]
304        pub unsafe fn headingOrientation(&self) -> CLDeviceOrientation;
305
306        /// Setter for [`headingOrientation`][Self::headingOrientation].
307        #[unsafe(method(setHeadingOrientation:))]
308        #[unsafe(method_family = none)]
309        pub unsafe fn setHeadingOrientation(&self, heading_orientation: CLDeviceOrientation);
310
311        #[cfg(feature = "CLHeading")]
312        #[unsafe(method(heading))]
313        #[unsafe(method_family = none)]
314        pub unsafe fn heading(&self) -> Option<Retained<CLHeading>>;
315
316        #[cfg(feature = "CLLocation")]
317        #[unsafe(method(maximumRegionMonitoringDistance))]
318        #[unsafe(method_family = none)]
319        pub unsafe fn maximumRegionMonitoringDistance(&self) -> CLLocationDistance;
320
321        #[cfg(feature = "CLRegion")]
322        #[unsafe(method(monitoredRegions))]
323        #[unsafe(method_family = none)]
324        pub unsafe fn monitoredRegions(&self) -> Retained<NSSet<CLRegion>>;
325
326        #[cfg(feature = "CLRegion")]
327        #[deprecated = "Use -rangedBeaconConstraints"]
328        #[unsafe(method(rangedRegions))]
329        #[unsafe(method_family = none)]
330        pub unsafe fn rangedRegions(&self) -> Retained<NSSet<CLRegion>>;
331
332        #[cfg(all(
333            feature = "CLBeaconIdentityCondition",
334            feature = "CLBeaconIdentityConstraint",
335            feature = "CLCondition"
336        ))]
337        #[unsafe(method(rangedBeaconConstraints))]
338        #[unsafe(method_family = none)]
339        pub unsafe fn rangedBeaconConstraints(&self)
340            -> Retained<NSSet<CLBeaconIdentityConstraint>>;
341
342        #[unsafe(method(requestWhenInUseAuthorization))]
343        #[unsafe(method_family = none)]
344        pub unsafe fn requestWhenInUseAuthorization(&self);
345
346        #[unsafe(method(requestAlwaysAuthorization))]
347        #[unsafe(method_family = none)]
348        pub unsafe fn requestAlwaysAuthorization(&self);
349
350        #[cfg(feature = "block2")]
351        #[unsafe(method(requestTemporaryFullAccuracyAuthorizationWithPurposeKey:completion:))]
352        #[unsafe(method_family = none)]
353        pub unsafe fn requestTemporaryFullAccuracyAuthorizationWithPurposeKey_completion(
354            &self,
355            purpose_key: &NSString,
356            completion: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
357        );
358
359        #[unsafe(method(requestTemporaryFullAccuracyAuthorizationWithPurposeKey:))]
360        #[unsafe(method_family = none)]
361        pub unsafe fn requestTemporaryFullAccuracyAuthorizationWithPurposeKey(
362            &self,
363            purpose_key: &NSString,
364        );
365
366        #[unsafe(method(startUpdatingLocation))]
367        #[unsafe(method_family = none)]
368        pub unsafe fn startUpdatingLocation(&self);
369
370        #[unsafe(method(stopUpdatingLocation))]
371        #[unsafe(method_family = none)]
372        pub unsafe fn stopUpdatingLocation(&self);
373
374        #[unsafe(method(requestLocation))]
375        #[unsafe(method_family = none)]
376        pub unsafe fn requestLocation(&self);
377
378        #[unsafe(method(startUpdatingHeading))]
379        #[unsafe(method_family = none)]
380        pub unsafe fn startUpdatingHeading(&self);
381
382        #[unsafe(method(stopUpdatingHeading))]
383        #[unsafe(method_family = none)]
384        pub unsafe fn stopUpdatingHeading(&self);
385
386        #[unsafe(method(dismissHeadingCalibrationDisplay))]
387        #[unsafe(method_family = none)]
388        pub unsafe fn dismissHeadingCalibrationDisplay(&self);
389
390        #[unsafe(method(startMonitoringSignificantLocationChanges))]
391        #[unsafe(method_family = none)]
392        pub unsafe fn startMonitoringSignificantLocationChanges(&self);
393
394        #[unsafe(method(stopMonitoringSignificantLocationChanges))]
395        #[unsafe(method_family = none)]
396        pub unsafe fn stopMonitoringSignificantLocationChanges(&self);
397
398        #[cfg(feature = "block2")]
399        #[unsafe(method(startMonitoringLocationPushesWithCompletion:))]
400        #[unsafe(method_family = none)]
401        pub unsafe fn startMonitoringLocationPushesWithCompletion(
402            &self,
403            completion: Option<&block2::DynBlock<dyn Fn(*mut NSData, *mut NSError)>>,
404        );
405
406        #[unsafe(method(stopMonitoringLocationPushes))]
407        #[unsafe(method_family = none)]
408        pub unsafe fn stopMonitoringLocationPushes(&self);
409
410        #[cfg(all(feature = "CLLocation", feature = "CLRegion"))]
411        #[deprecated]
412        #[unsafe(method(startMonitoringForRegion:desiredAccuracy:))]
413        #[unsafe(method_family = none)]
414        pub unsafe fn startMonitoringForRegion_desiredAccuracy(
415            &self,
416            region: &CLRegion,
417            accuracy: CLLocationAccuracy,
418        );
419
420        #[cfg(feature = "CLRegion")]
421        #[deprecated]
422        #[unsafe(method(stopMonitoringForRegion:))]
423        #[unsafe(method_family = none)]
424        pub unsafe fn stopMonitoringForRegion(&self, region: &CLRegion);
425
426        #[cfg(feature = "CLRegion")]
427        #[deprecated]
428        #[unsafe(method(startMonitoringForRegion:))]
429        #[unsafe(method_family = none)]
430        pub unsafe fn startMonitoringForRegion(&self, region: &CLRegion);
431
432        #[cfg(feature = "CLRegion")]
433        #[deprecated]
434        #[unsafe(method(requestStateForRegion:))]
435        #[unsafe(method_family = none)]
436        pub unsafe fn requestStateForRegion(&self, region: &CLRegion);
437
438        #[cfg(all(feature = "CLBeaconRegion", feature = "CLRegion"))]
439        #[deprecated = "Use -startRangingBeaconsSatisfyingConstraint:"]
440        #[unsafe(method(startRangingBeaconsInRegion:))]
441        #[unsafe(method_family = none)]
442        pub unsafe fn startRangingBeaconsInRegion(&self, region: &CLBeaconRegion);
443
444        #[cfg(all(feature = "CLBeaconRegion", feature = "CLRegion"))]
445        #[deprecated = "Use -stopRangingBeaconsSatisfyingConstraint:"]
446        #[unsafe(method(stopRangingBeaconsInRegion:))]
447        #[unsafe(method_family = none)]
448        pub unsafe fn stopRangingBeaconsInRegion(&self, region: &CLBeaconRegion);
449
450        #[cfg(all(
451            feature = "CLBeaconIdentityCondition",
452            feature = "CLBeaconIdentityConstraint",
453            feature = "CLCondition"
454        ))]
455        #[unsafe(method(startRangingBeaconsSatisfyingConstraint:))]
456        #[unsafe(method_family = none)]
457        pub unsafe fn startRangingBeaconsSatisfyingConstraint(
458            &self,
459            constraint: &CLBeaconIdentityConstraint,
460        );
461
462        #[cfg(all(
463            feature = "CLBeaconIdentityCondition",
464            feature = "CLBeaconIdentityConstraint",
465            feature = "CLCondition"
466        ))]
467        #[unsafe(method(stopRangingBeaconsSatisfyingConstraint:))]
468        #[unsafe(method_family = none)]
469        pub unsafe fn stopRangingBeaconsSatisfyingConstraint(
470            &self,
471            constraint: &CLBeaconIdentityConstraint,
472        );
473
474        #[cfg(feature = "CLLocation")]
475        #[deprecated = "You can remove calls to this method"]
476        #[unsafe(method(allowDeferredLocationUpdatesUntilTraveled:timeout:))]
477        #[unsafe(method_family = none)]
478        pub unsafe fn allowDeferredLocationUpdatesUntilTraveled_timeout(
479            &self,
480            distance: CLLocationDistance,
481            timeout: NSTimeInterval,
482        );
483
484        #[deprecated = "You can remove calls to this method"]
485        #[unsafe(method(disallowDeferredLocationUpdates))]
486        #[unsafe(method_family = none)]
487        pub unsafe fn disallowDeferredLocationUpdates(&self);
488
489        #[deprecated = "You can remove calls to this method"]
490        #[unsafe(method(deferredLocationUpdatesAvailable))]
491        #[unsafe(method_family = none)]
492        pub unsafe fn deferredLocationUpdatesAvailable() -> bool;
493
494        #[cfg(all(feature = "CLLocation", feature = "block2"))]
495        #[unsafe(method(requestHistoricalLocationsWithPurposeKey:sampleCount:completionHandler:))]
496        #[unsafe(method_family = none)]
497        pub unsafe fn requestHistoricalLocationsWithPurposeKey_sampleCount_completionHandler(
498            &self,
499            purpose_key: &NSString,
500            sample_count: NSInteger,
501            handler: &block2::DynBlock<dyn Fn(NonNull<NSArray<CLLocation>>, *mut NSError)>,
502        );
503    );
504}
505
506/// Methods declared on superclass `NSObject`.
507impl CLLocationManager {
508    extern_methods!(
509        #[unsafe(method(init))]
510        #[unsafe(method_family = init)]
511        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
512
513        #[unsafe(method(new))]
514        #[unsafe(method_family = new)]
515        pub unsafe fn new() -> Retained<Self>;
516    );
517}