objc2-shared-with-you 0.3.2

Bindings to the SharedWithYou 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::*;
#[cfg(feature = "objc2-shared-with-you-core")]
use objc2_shared_with_you_core::*;

use crate::*;

extern_protocol!(
    /// The delegate is notified when there are changes to the list of surfaced highlights, or when the enablement settings change.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/sharedwithyou/swhighlightcenterdelegate?language=objc)
    pub unsafe trait SWHighlightCenterDelegate: NSObjectProtocol {
        /// Notifies the delegate that the list, or rank order of surfaced highlights has changed.
        ///
        /// When this method is called, it is the app's responsibility to update any displayed highlights to match the updated list. Only the highlights provided should have an indication of having been shared. If no highlights are provided in the list, any links previously indicated as shared should be removed. The array is a priority-ordered list, where the first element in the array is deemed to be most relevant to the user at the time this method is called. The list of provided highlights will be empty if there are no highlights, or when the user has not given permission for a particular app to display highlights.
        #[unsafe(method(highlightCenterHighlightsDidChange:))]
        #[unsafe(method_family = none)]
        unsafe fn highlightCenterHighlightsDidChange(&self, highlight_center: &SWHighlightCenter);
    }
);

extern_class!(
    /// Provides the application with a priority-ordered list of universal links which have been shared with the current user.
    ///
    /// The system decides which links should be surfaced. The app is responsible for updating its UI to reflect the latest provided list.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/sharedwithyou/swhighlightcenter?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct SWHighlightCenter;
);

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

impl SWHighlightCenter {
    extern_methods!(
        /// The highlight center's delegate
        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub unsafe fn delegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn SWHighlightCenterDelegate>>>;

        /// 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 SWHighlightCenterDelegate>>,
        );

        #[cfg(feature = "SWHighlight")]
        #[unsafe(method(highlights))]
        #[unsafe(method_family = none)]
        pub unsafe fn highlights(&self) -> Retained<NSArray<SWHighlight>>;

        /// Localized title to display with a collection of highlights
        ///
        /// Use this string as the title for a collection of shared highlight links displayed to the user.
        #[unsafe(method(highlightCollectionTitle))]
        #[unsafe(method_family = none)]
        pub unsafe fn highlightCollectionTitle() -> Retained<NSString>;

        /// Whether the current software version has full support for Messages collaboration features.
        ///
        /// Use this property at runtime to conditionally enable Messages collaboration features in your app. This property will be permantently set to YES on a software version with full support for these features.
        #[unsafe(method(isSystemCollaborationSupportAvailable))]
        #[unsafe(method_family = none)]
        pub unsafe fn isSystemCollaborationSupportAvailable() -> bool;

        #[cfg(all(feature = "SWHighlight", feature = "block2"))]
        /// A convenience method to get a SWHighlight for a given URL
        ///
        /// Parameter `URL`: The URL used to find the SWHighlight
        ///
        /// Parameter `completionHandler`: an SWHighlight if it  was fetched. The completion handler will always be invoked on the main queue
        #[unsafe(method(getHighlightForURL:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn getHighlightForURL_completionHandler(
            &self,
            url: &NSURL,
            completion_handler: &block2::DynBlock<dyn Fn(*mut SWHighlight, *mut NSError)>,
        );

        #[cfg(all(
            feature = "SWCollaborationHighlight",
            feature = "SWHighlight",
            feature = "objc2-shared-with-you-core"
        ))]
        #[unsafe(method(collaborationHighlightForIdentifier:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn collaborationHighlightForIdentifier_error(
            &self,
            collaboration_identifier: &SWCollaborationIdentifier,
        ) -> Result<Retained<SWCollaborationHighlight>, Retained<NSError>>;

        #[cfg(all(
            feature = "SWCollaborationHighlight",
            feature = "SWHighlight",
            feature = "block2"
        ))]
        /// A convenience method to get an SWCollaborationHighlight for a given URL
        ///
        /// Parameter `URL`: The URL used to find the SWCollaborationHighlight
        ///
        /// Parameter `completionHandler`: an SWCollaborationHighlight if it was fetched. The completion handler will always be invoked on the main queue
        #[unsafe(method(getCollaborationHighlightForURL:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn getCollaborationHighlightForURL_completionHandler(
            &self,
            url: &NSURL,
            completion_handler: &block2::DynBlock<
                dyn Fn(*mut SWCollaborationHighlight, *mut NSError),
            >,
        );

        #[cfg(feature = "SWHighlightEvent")]
        /// Post a given event to the highlight center for display in Messages.
        ///
        /// Parameter `event`: The event to add for a specific highlight
        #[unsafe(method(postNoticeForHighlightEvent:))]
        #[unsafe(method_family = none)]
        pub unsafe fn postNoticeForHighlightEvent(
            &self,
            event: &ProtocolObject<dyn SWHighlightEvent>,
        );

        #[cfg(all(feature = "SWCollaborationHighlight", feature = "SWHighlight"))]
        /// Clear notices for a given collaboration highlight in Messages.
        ///
        /// Parameter `highlight`: The highlight to clear notices from.
        #[unsafe(method(clearNoticesForHighlight:))]
        #[unsafe(method_family = none)]
        pub unsafe fn clearNoticesForHighlight(&self, highlight: &SWCollaborationHighlight);

        #[cfg(all(
            feature = "SWCollaborationHighlight",
            feature = "SWHighlight",
            feature = "block2",
            feature = "objc2-shared-with-you-core"
        ))]
        /// Method to sign passed in data with local device's private key
        ///
        /// Parameter `data`: NSData that needs to be signed
        ///
        /// Parameter `collaborationHighlight`: The corresponding collaboration highlight.
        ///
        /// Parameter `completionHandler`: Signed data along with proof of inclusion for merkle if signing succeeded, otherwise an error. The completion handler will always be invoked on main queue
        #[unsafe(method(getSignedIdentityProofForCollaborationHighlight:usingData:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn getSignedIdentityProofForCollaborationHighlight_usingData_completionHandler(
            &self,
            collaboration_highlight: &SWCollaborationHighlight,
            data: &NSData,
            completion_handler: &block2::DynBlock<
                dyn Fn(*mut SWSignedPersonIdentityProof, *mut NSError),
            >,
        );
    );
}

/// Methods declared on superclass `NSObject`.
impl SWHighlightCenter {
    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>;
    );
}