objc2-sensitive-content-analysis 0.3.2

Bindings to the SensitiveContentAnalysis 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::*;
#[cfg(feature = "objc2-core-graphics")]
use objc2_core_graphics::*;
use objc2_foundation::*;

use crate::*;

/// SensitivityAnalysis Policy on device, represents type of interventions when enabled
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/sensitivecontentanalysis/scsensitivityanalysispolicy?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SCSensitivityAnalysisPolicy(pub NSInteger);
impl SCSensitivityAnalysisPolicy {
    /// No feature enabled that is requiring Sensitive Analysis on device, analysis will be disabled
    #[doc(alias = "SCSensitivityAnalysisPolicyDisabled")]
    pub const Disabled: Self = Self(0);
    /// Sensitive Analysis is enabled on device through "Sensitive Content Warning" in Settings.
    /// It is expected that brief/inline UI, like simple "show" button.
    #[doc(alias = "SCSensitivityAnalysisPolicySimpleInterventions")]
    pub const SimpleInterventions: Self = Self(1);
    /// Sensitive Analysis is enabled for kids or teens in ScreenTime through "Communications Safety" feature.
    /// It's expected to have more descriptive UI for the user, explaining potential risks.
    #[doc(alias = "SCSensitivityAnalysisPolicyDescriptiveInterventions")]
    pub const DescriptiveInterventions: Self = Self(2);
}

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

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

extern_class!(
    /// Main class for content sensitivity analysis
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/sensitivecontentanalysis/scsensitivityanalyzer?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct SCSensitivityAnalyzer;
);

unsafe impl Send for SCSensitivityAnalyzer {}

unsafe impl Sync for SCSensitivityAnalyzer {}

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

impl SCSensitivityAnalyzer {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        /// Current SCSensitivityAnalysisPolicy set on device. Can be used to determine whether analysis is available or not
        #[unsafe(method(analysisPolicy))]
        #[unsafe(method_family = none)]
        pub unsafe fn analysisPolicy(&self) -> SCSensitivityAnalysisPolicy;

        #[cfg(all(feature = "SCSensitivityAnalysis", feature = "block2"))]
        /// Analyze sensitivity of Image File on disk (only local fileURL)
        ///
        /// Parameter `fileURL`: Image file location on disk
        ///
        /// Parameter `completionHandler`: Block to be called on completion (callback is called on unspecified queue)
        #[unsafe(method(analyzeImageFile:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn analyzeImageFile_completionHandler(
            &self,
            file_url: &NSURL,
            completion_handler: &block2::DynBlock<dyn Fn(*mut SCSensitivityAnalysis, *mut NSError)>,
        );

        #[cfg(all(
            feature = "SCSensitivityAnalysis",
            feature = "block2",
            feature = "objc2-core-graphics"
        ))]
        /// Analyze sensitivity of CGImage in memory
        ///
        /// Parameter `image`: CGImage reference
        ///
        /// Parameter `completionHandler`: Block to be called on completion (callback is called on unspecified queue)
        #[unsafe(method(analyzeCGImage:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn analyzeCGImage_completionHandler(
            &self,
            image: &CGImage,
            completion_handler: &block2::DynBlock<dyn Fn(*mut SCSensitivityAnalysis, *mut NSError)>,
        );

        #[cfg(all(feature = "SCSensitivityAnalysis", feature = "block2"))]
        /// Analyze sensitivity of Video File on disk.
        ///
        /// Parameter `fileURL`: Video file location on disk
        ///
        /// Parameter `completionHandler`: Block to be called on completion (callback is called on unspecified queue)
        ///
        /// Returns: An NSProgress instance for tracking video file analysis progress
        #[unsafe(method(analyzeVideoFile:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn analyzeVideoFile_completionHandler(
            &self,
            file_url: &NSURL,
            completion_handler: &block2::DynBlock<dyn Fn(*mut SCSensitivityAnalysis, *mut NSError)>,
        ) -> Retained<NSProgress>;
    );
}

/// Methods declared on superclass `NSObject`.
impl SCSensitivityAnalyzer {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}