objc2-image-capture-core 0.3.2

Bindings to the ImageCaptureCore 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::*;

extern "C" {
    /// ICButtonTypeScan
    ///
    /// Indicates that the "Scan" button on the device was pressed.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/imagecapturecore/icbuttontypescan?language=objc)
    pub static ICButtonTypeScan: &'static NSString;
}

extern "C" {
    /// ICButtonTypeMail
    ///
    /// Indicates that the "Mail" button on the device was pressed.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/imagecapturecore/icbuttontypemail?language=objc)
    pub static ICButtonTypeMail: &'static NSString;
}

extern "C" {
    /// ICButtonTypeCopy
    ///
    /// Indicates that the "Copy" button on the device was pressed.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/imagecapturecore/icbuttontypecopy?language=objc)
    pub static ICButtonTypeCopy: &'static NSString;
}

extern "C" {
    /// ICButtonTypeWeb
    ///
    /// Indicates that the "Web" button on the device was pressed.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/imagecapturecore/icbuttontypeweb?language=objc)
    pub static ICButtonTypeWeb: &'static NSString;
}

extern "C" {
    /// ICButtonTypePrint
    ///
    /// Indicates that the "Print" button on the device was pressed.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/imagecapturecore/icbuttontypeprint?language=objc)
    pub static ICButtonTypePrint: &'static NSString;
}

extern "C" {
    /// ICButtonTypeTransfer
    ///
    /// Indicates that the "Transfer" button on the device was pressed.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/imagecapturecore/icbuttontypetransfer?language=objc)
    pub static ICButtonTypeTransfer: &'static NSString;
}

extern "C" {
    /// ICScannerStatusWarmingUp
    ///
    /// A non-localized notification string to indicate that the scanner is warming up.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/imagecapturecore/icscannerstatuswarmingup?language=objc)
    pub static ICScannerStatusWarmingUp: &'static NSString;
}

extern "C" {
    /// ICScannerStatusWarmUpDone
    ///
    /// A non-localized notification string to indicate that the scanner has warmed up.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/imagecapturecore/icscannerstatuswarmupdone?language=objc)
    pub static ICScannerStatusWarmUpDone: &'static NSString;
}

extern "C" {
    /// ICScannerStatusRequestsOverviewScan
    ///
    /// A non-localized notification string to indicate that the scanner is requesting an overview scan to be performed.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/imagecapturecore/icscannerstatusrequestsoverviewscan?language=objc)
    pub static ICScannerStatusRequestsOverviewScan: &'static NSString;
}

/// Transfer mode to be used when transferring scan data from the scanner functional unit.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/imagecapturecore/icscannertransfermode?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct ICScannerTransferMode(pub NSUInteger);
impl ICScannerTransferMode {
    #[doc(alias = "ICScannerTransferModeFileBased")]
    pub const FileBased: Self = Self(0);
    #[doc(alias = "ICScannerTransferModeMemoryBased")]
    pub const MemoryBased: Self = Self(1);
}

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

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

extern_protocol!(
    /// A delegate of ICScannerDevice must conform to ICScannerDeviceDelegate protocol.
    ///
    /// The ICScannerDeviceDelegate protocol inherits from the ICDeviceDelegate protocol.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/imagecapturecore/icscannerdevicedelegate?language=objc)
    #[cfg(feature = "ICDevice")]
    pub unsafe trait ICScannerDeviceDelegate: ICDeviceDelegate {
        /// This message is sent when another client closes an open session on the scanner.
        ///
        /// Scanners require exclusive access, only one client can open a session on a scanner. The scanner is available if it does not have a session opened by another client. Attempting to open a session on a scanner that already has an open session for another client will result in an error. A client that wants to open a session on a scanner as soon as it is available should implement this method and send "requestOpenSession" message to scanner object from that method.
        #[optional]
        #[unsafe(method(scannerDeviceDidBecomeAvailable:))]
        #[unsafe(method_family = none)]
        unsafe fn scannerDeviceDidBecomeAvailable(&self, scanner: &ICScannerDevice);

        #[cfg(feature = "ICScannerFunctionalUnits")]
        /// This message is sent when a functional unit is selected on the scanner device.
        ///
        /// A functional unit is selected immediately after the scanner device is instantiated and in response to "requestSelectFunctionalUnit:" message.
        #[optional]
        #[unsafe(method(scannerDevice:didSelectFunctionalUnit:error:))]
        #[unsafe(method_family = none)]
        unsafe fn scannerDevice_didSelectFunctionalUnit_error(
            &self,
            scanner: &ICScannerDevice,
            functional_unit: &ICScannerFunctionalUnit,
            error: Option<&NSError>,
        );

        /// This message is sent when the scanner device receives the requested scan. If selectedFunctionalUnit is a document feeder, then this message will be sent once for each scanned page.
        ///
        /// This method has been deprecated and superceded by the didScanToURL: method for file based transfer, along with the didScanToBandData: for memory based transfer.
        #[deprecated = "Use didScanToURL: for file URLs and didScanToBandData: for memory based transfers"]
        #[optional]
        #[unsafe(method(scannerDevice:didScanToURL:data:))]
        #[unsafe(method_family = none)]
        unsafe fn scannerDevice_didScanToURL_data(
            &self,
            scanner: &ICScannerDevice,
            url: &NSURL,
            data: &NSData,
        );

        /// This message is sent when the scanner device receives the requested scan. If selectedFunctionalUnit is a document feeder, then this message will be sent once for each scanned page.
        ///
        /// This message is sent when the scanner device receives the requested scan. If selectedFunctionalUnit is a document feeder, then this message will be sent once for each scanned page.
        #[optional]
        #[unsafe(method(scannerDevice:didScanToURL:))]
        #[unsafe(method_family = none)]
        unsafe fn scannerDevice_didScanToURL(&self, scanner: &ICScannerDevice, url: &NSURL);

        #[cfg(feature = "ICScannerBandData")]
        /// This message is sent when the scanner device receives the requested scan progress notification and a band of data is sent for each notification received.
        ///
        /// In memory transfer mode, this will send a band of size that has been selected by the client via the maxMemoryBandSize property.
        #[optional]
        #[unsafe(method(scannerDevice:didScanToBandData:))]
        #[unsafe(method_family = none)]
        unsafe fn scannerDevice_didScanToBandData(
            &self,
            scanner: &ICScannerDevice,
            data: &ICScannerBandData,
        );

        /// This message is sent after the scanner device completes an overview scan.
        ///
        /// This message is sent after the scanner device completes an overview scan.
        #[optional]
        #[unsafe(method(scannerDevice:didCompleteOverviewScanWithError:))]
        #[unsafe(method_family = none)]
        unsafe fn scannerDevice_didCompleteOverviewScanWithError(
            &self,
            scanner: &ICScannerDevice,
            error: Option<&NSError>,
        );

        /// This message is sent after the scanner device completes a scan.
        ///
        /// This message is sent after the scanner device completes a scan.
        #[optional]
        #[unsafe(method(scannerDevice:didCompleteScanWithError:))]
        #[unsafe(method_family = none)]
        unsafe fn scannerDevice_didCompleteScanWithError(
            &self,
            scanner: &ICScannerDevice,
            error: Option<&NSError>,
        );
    }
);

extern_class!(
    /// ICScannerDevice is a concrete subclass of ICDevice class. ICDeviceBrowser creates instances of this class.
    ///
    /// In this release, an instance of ICScannerDevice class is intended to be used by the ICScannerDeviceView object. The ICScannerDeviceView class encapsulates the complexities of setting scan parameters, performing scans and saving the result. The developer should consider using ICScannerDeviceView instead of building their own views using the ICScannerDevice object.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/imagecapturecore/icscannerdevice?language=objc)
    #[unsafe(super(ICDevice, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "ICDevice")]
    pub struct ICScannerDevice;
);

#[cfg(feature = "ICDevice")]
extern_conformance!(
    unsafe impl NSObjectProtocol for ICScannerDevice {}
);

#[cfg(feature = "ICDevice")]
impl ICScannerDevice {
    extern_methods!(
        /// An array of functional unit types available on this scanner device. This is an array of NSNumber objects whose values are of type ICScannerFunctionalUnitType.
        #[unsafe(method(availableFunctionalUnitTypes))]
        #[unsafe(method_family = none)]
        pub unsafe fn availableFunctionalUnitTypes(&self) -> Retained<NSArray<NSNumber>>;

        #[cfg(feature = "ICScannerFunctionalUnits")]
        /// The currently selected functional unit on the scanner device.
        #[unsafe(method(selectedFunctionalUnit))]
        #[unsafe(method_family = none)]
        pub unsafe fn selectedFunctionalUnit(&self) -> Retained<ICScannerFunctionalUnit>;

        /// The transfer mode for scanned document.
        #[unsafe(method(transferMode))]
        #[unsafe(method_family = none)]
        pub unsafe fn transferMode(&self) -> ICScannerTransferMode;

        /// Setter for [`transferMode`][Self::transferMode].
        #[unsafe(method(setTransferMode:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setTransferMode(&self, transfer_mode: ICScannerTransferMode);

        /// The total maximum band size requested when performing a ICScannerTransferModeMemoryBased.
        #[unsafe(method(maxMemoryBandSize))]
        #[unsafe(method_family = none)]
        pub unsafe fn maxMemoryBandSize(&self) -> u32;

        /// Setter for [`maxMemoryBandSize`][Self::maxMemoryBandSize].
        #[unsafe(method(setMaxMemoryBandSize:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setMaxMemoryBandSize(&self, max_memory_band_size: u32);

        /// The downloads directory.
        #[unsafe(method(downloadsDirectory))]
        #[unsafe(method_family = none)]
        pub unsafe fn downloadsDirectory(&self) -> Retained<NSURL>;

        /// Setter for [`downloadsDirectory`][Self::downloadsDirectory].
        #[unsafe(method(setDownloadsDirectory:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDownloadsDirectory(&self, downloads_directory: &NSURL);

        /// The document name.
        #[unsafe(method(documentName))]
        #[unsafe(method_family = none)]
        pub unsafe fn documentName(&self) -> Retained<NSString>;

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

        /// The document UTI. Currently supported UTIs are: kUTTypeJPEG, kUTTypeJPEG2000, kUTTypeTIFF, kUTTypePNG etc.
        #[unsafe(method(documentUTI))]
        #[unsafe(method_family = none)]
        pub unsafe fn documentUTI(&self) -> Retained<NSString>;

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

        /// If the device is protected, instead of prompting the user for a username, this property
        /// can be set to default to a specific username as a convience.  The value will persist until
        /// reset by setting it to nil.
        #[unsafe(method(defaultUsername))]
        #[unsafe(method_family = none)]
        pub unsafe fn defaultUsername(&self) -> Retained<NSString>;

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

        /// This message requests to open a session on the protected device with the authorized username and
        /// passcode.  If the device reports back a failure of credentials, they can be provided here for the
        /// launch.
        /// A client MUST open a session on a device in order to use the device.
        ///
        /// Make sure the receiver's delegate is set prior to sending this message; otherwise this message will be ignored. This request is completed when the delegate receives a "device:didOpenSessionWithError:" message. No more messages will be sent to the delegate if this request fails.
        #[unsafe(method(requestOpenSessionWithCredentials:password:))]
        #[unsafe(method_family = none)]
        pub unsafe fn requestOpenSessionWithCredentials_password(
            &self,
            username: &NSString,
            password: &NSString,
        );

        #[cfg(feature = "ICScannerFunctionalUnits")]
        /// Requests the scanner device to select a functional unit.
        ///
        /// When this request is completed, the delegate will be notified using the 'scannerDevice:didSelectFunctionalUnit:error:' message.
        #[unsafe(method(requestSelectFunctionalUnit:))]
        #[unsafe(method_family = none)]
        pub unsafe fn requestSelectFunctionalUnit(&self, r#type: ICScannerFunctionalUnitType);

        /// Starts an overview scan on selectedFunctionalUnit.
        ///
        /// When this request is completed, the delegate will be notified using the 'scannerDevice:didCompleteOverviewScanWithError:' message. The content of error returned should be examined to determine if the request completed successfully.
        #[unsafe(method(requestOverviewScan))]
        #[unsafe(method_family = none)]
        pub unsafe fn requestOverviewScan(&self);

        /// Starts a scan on selectedFunctionalUnit.
        ///
        /// When this request is completed, the delegate will be notified using the 'scannerDevice:didCompleteScanWithError:' message. The content of error returned should be examined to determine if the request completed successfully.
        #[unsafe(method(requestScan))]
        #[unsafe(method_family = none)]
        pub unsafe fn requestScan(&self);

        /// Cancels the current scan operation started by sending a 'requestOverviewScan' or 'requestScan'.
        #[unsafe(method(cancelScan))]
        #[unsafe(method_family = none)]
        pub unsafe fn cancelScan(&self);
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "ICDevice")]
impl ICScannerDevice {
    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>;
    );
}