objc2-map-kit 0.3.2

Bindings to the MapKit framework
Documentation
//! 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::*;

/// [Apple's documentation](https://developer.apple.com/documentation/mapkit/mksearchcompletionfiltertype?language=objc)
// NS_ENUM
#[deprecated = "Use MKLocalSearchCompleterResultType"]
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MKSearchCompletionFilterType(pub NSInteger);
impl MKSearchCompletionFilterType {
    #[doc(alias = "MKSearchCompletionFilterTypeLocationsAndQueries")]
    #[deprecated = "Use MKLocalSearchCompleterResultType"]
    pub const LocationsAndQueries: Self = Self(0);
    #[doc(alias = "MKSearchCompletionFilterTypeLocationsOnly")]
    #[deprecated = "Use MKLocalSearchCompleterResultType"]
    pub const LocationsOnly: Self = Self(1);
}

unsafe impl Encode for MKSearchCompletionFilterType {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for MKSearchCompletionFilterType {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/mapkit/mklocalsearchcompleterresulttype?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MKLocalSearchCompleterResultType(pub NSUInteger);
bitflags::bitflags! {
    impl MKLocalSearchCompleterResultType: NSUInteger {
        #[doc(alias = "MKLocalSearchCompleterResultTypeAddress")]
        const Address = 1<<0;
        #[doc(alias = "MKLocalSearchCompleterResultTypePointOfInterest")]
        const PointOfInterest = 1<<1;
        #[doc(alias = "MKLocalSearchCompleterResultTypeQuery")]
        const Query = 1<<2;
        #[doc(alias = "MKLocalSearchCompleterResultTypePhysicalFeature")]
        const PhysicalFeature = 1<<3;
    }
}

unsafe impl Encode for MKLocalSearchCompleterResultType {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for MKLocalSearchCompleterResultType {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/mapkit/mklocalsearchcompleter?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MKLocalSearchCompleter;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for MKLocalSearchCompleter {}
);

impl MKLocalSearchCompleter {
    extern_methods!(
        #[unsafe(method(queryFragment))]
        #[unsafe(method_family = none)]
        pub unsafe fn queryFragment(&self) -> Retained<NSString>;

        /// Setter for [`queryFragment`][Self::queryFragment].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setQueryFragment:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setQueryFragment(&self, query_fragment: &NSString);

        #[cfg(all(feature = "MKGeometry", feature = "objc2-core-location"))]
        #[unsafe(method(region))]
        #[unsafe(method_family = none)]
        pub unsafe fn region(&self) -> MKCoordinateRegion;

        #[cfg(all(feature = "MKGeometry", feature = "objc2-core-location"))]
        /// Setter for [`region`][Self::region].
        #[unsafe(method(setRegion:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setRegion(&self, region: MKCoordinateRegion);

        #[cfg(feature = "MKTypes")]
        #[unsafe(method(regionPriority))]
        #[unsafe(method_family = none)]
        pub unsafe fn regionPriority(&self) -> MKLocalSearchRegionPriority;

        #[cfg(feature = "MKTypes")]
        /// Setter for [`regionPriority`][Self::regionPriority].
        #[unsafe(method(setRegionPriority:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setRegionPriority(&self, region_priority: MKLocalSearchRegionPriority);

        #[deprecated = "Use resultTypes"]
        #[unsafe(method(filterType))]
        #[unsafe(method_family = none)]
        pub unsafe fn filterType(&self) -> MKSearchCompletionFilterType;

        /// Setter for [`filterType`][Self::filterType].
        #[deprecated = "Use resultTypes"]
        #[unsafe(method(setFilterType:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setFilterType(&self, filter_type: MKSearchCompletionFilterType);

        #[unsafe(method(resultTypes))]
        #[unsafe(method_family = none)]
        pub unsafe fn resultTypes(&self) -> MKLocalSearchCompleterResultType;

        /// Setter for [`resultTypes`][Self::resultTypes].
        #[unsafe(method(setResultTypes:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setResultTypes(&self, result_types: MKLocalSearchCompleterResultType);

        #[cfg(feature = "MKPointOfInterestFilter")]
        #[unsafe(method(pointOfInterestFilter))]
        #[unsafe(method_family = none)]
        pub unsafe fn pointOfInterestFilter(&self) -> Option<Retained<MKPointOfInterestFilter>>;

        #[cfg(feature = "MKPointOfInterestFilter")]
        /// Setter for [`pointOfInterestFilter`][Self::pointOfInterestFilter].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setPointOfInterestFilter:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPointOfInterestFilter(
            &self,
            point_of_interest_filter: Option<&MKPointOfInterestFilter>,
        );

        #[cfg(feature = "MKAddressFilter")]
        #[unsafe(method(addressFilter))]
        #[unsafe(method_family = none)]
        pub unsafe fn addressFilter(&self) -> Option<Retained<MKAddressFilter>>;

        #[cfg(feature = "MKAddressFilter")]
        /// Setter for [`addressFilter`][Self::addressFilter].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setAddressFilter:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAddressFilter(&self, address_filter: Option<&MKAddressFilter>);

        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub unsafe fn delegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn MKLocalSearchCompleterDelegate>>>;

        /// Setter for [`delegate`][Self::delegate].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        #[unsafe(method(setDelegate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDelegate(
            &self,
            delegate: Option<&ProtocolObject<dyn MKLocalSearchCompleterDelegate>>,
        );

        #[unsafe(method(results))]
        #[unsafe(method_family = none)]
        pub unsafe fn results(&self) -> Retained<NSArray<MKLocalSearchCompletion>>;

        #[unsafe(method(isSearching))]
        #[unsafe(method_family = none)]
        pub unsafe fn isSearching(&self) -> bool;

        #[unsafe(method(cancel))]
        #[unsafe(method_family = none)]
        pub unsafe fn cancel(&self);
    );
}

/// Methods declared on superclass `NSObject`.
impl MKLocalSearchCompleter {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/mapkit/mklocalsearchcompleterdelegate?language=objc)
    pub unsafe trait MKLocalSearchCompleterDelegate: NSObjectProtocol {
        #[optional]
        #[unsafe(method(completerDidUpdateResults:))]
        #[unsafe(method_family = none)]
        unsafe fn completerDidUpdateResults(&self, completer: &MKLocalSearchCompleter);

        #[optional]
        #[unsafe(method(completer:didFailWithError:))]
        #[unsafe(method_family = none)]
        unsafe fn completer_didFailWithError(
            &self,
            completer: &MKLocalSearchCompleter,
            error: &NSError,
        );
    }
);

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/mapkit/mklocalsearchcompletion?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MKLocalSearchCompletion;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for MKLocalSearchCompletion {}
);

impl MKLocalSearchCompletion {
    extern_methods!(
        #[unsafe(method(title))]
        #[unsafe(method_family = none)]
        pub unsafe fn title(&self) -> Retained<NSString>;

        #[unsafe(method(titleHighlightRanges))]
        #[unsafe(method_family = none)]
        pub unsafe fn titleHighlightRanges(&self) -> Retained<NSArray<NSValue>>;

        #[unsafe(method(subtitle))]
        #[unsafe(method_family = none)]
        pub unsafe fn subtitle(&self) -> Retained<NSString>;

        #[unsafe(method(subtitleHighlightRanges))]
        #[unsafe(method_family = none)]
        pub unsafe fn subtitleHighlightRanges(&self) -> Retained<NSArray<NSValue>>;
    );
}

/// Methods declared on superclass `NSObject`.
impl MKLocalSearchCompletion {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

#[cfg(feature = "MKLocalSearchRequest")]
impl MKLocalSearchRequest {
    extern_methods!(
        #[unsafe(method(initWithCompletion:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithCompletion(
            this: Allocated<Self>,
            completion: &MKLocalSearchCompletion,
        ) -> Retained<Self>;
    );
}