objc2_image_capture_core/generated/
ICScannerDevice.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
10extern "C" {
11    /// ICButtonTypeScan
12    ///
13    /// Indicates that the "Scan" button on the device was pressed.
14    ///
15    /// See also [Apple's documentation](https://developer.apple.com/documentation/imagecapturecore/icbuttontypescan?language=objc)
16    pub static ICButtonTypeScan: &'static NSString;
17}
18
19extern "C" {
20    /// ICButtonTypeMail
21    ///
22    /// Indicates that the "Mail" button on the device was pressed.
23    ///
24    /// See also [Apple's documentation](https://developer.apple.com/documentation/imagecapturecore/icbuttontypemail?language=objc)
25    pub static ICButtonTypeMail: &'static NSString;
26}
27
28extern "C" {
29    /// ICButtonTypeCopy
30    ///
31    /// Indicates that the "Copy" button on the device was pressed.
32    ///
33    /// See also [Apple's documentation](https://developer.apple.com/documentation/imagecapturecore/icbuttontypecopy?language=objc)
34    pub static ICButtonTypeCopy: &'static NSString;
35}
36
37extern "C" {
38    /// ICButtonTypeWeb
39    ///
40    /// Indicates that the "Web" button on the device was pressed.
41    ///
42    /// See also [Apple's documentation](https://developer.apple.com/documentation/imagecapturecore/icbuttontypeweb?language=objc)
43    pub static ICButtonTypeWeb: &'static NSString;
44}
45
46extern "C" {
47    /// ICButtonTypePrint
48    ///
49    /// Indicates that the "Print" button on the device was pressed.
50    ///
51    /// See also [Apple's documentation](https://developer.apple.com/documentation/imagecapturecore/icbuttontypeprint?language=objc)
52    pub static ICButtonTypePrint: &'static NSString;
53}
54
55extern "C" {
56    /// ICButtonTypeTransfer
57    ///
58    /// Indicates that the "Transfer" button on the device was pressed.
59    ///
60    /// See also [Apple's documentation](https://developer.apple.com/documentation/imagecapturecore/icbuttontypetransfer?language=objc)
61    pub static ICButtonTypeTransfer: &'static NSString;
62}
63
64extern "C" {
65    /// ICScannerStatusWarmingUp
66    ///
67    /// A non-localized notification string to indicate that the scanner is warming up.
68    ///
69    /// See also [Apple's documentation](https://developer.apple.com/documentation/imagecapturecore/icscannerstatuswarmingup?language=objc)
70    pub static ICScannerStatusWarmingUp: &'static NSString;
71}
72
73extern "C" {
74    /// ICScannerStatusWarmUpDone
75    ///
76    /// A non-localized notification string to indicate that the scanner has warmed up.
77    ///
78    /// See also [Apple's documentation](https://developer.apple.com/documentation/imagecapturecore/icscannerstatuswarmupdone?language=objc)
79    pub static ICScannerStatusWarmUpDone: &'static NSString;
80}
81
82extern "C" {
83    /// ICScannerStatusRequestsOverviewScan
84    ///
85    /// A non-localized notification string to indicate that the scanner is requesting an overview scan to be performed.
86    ///
87    /// See also [Apple's documentation](https://developer.apple.com/documentation/imagecapturecore/icscannerstatusrequestsoverviewscan?language=objc)
88    pub static ICScannerStatusRequestsOverviewScan: &'static NSString;
89}
90
91/// Transfer mode to be used when transferring scan data from the scanner functional unit.
92///
93/// See also [Apple's documentation](https://developer.apple.com/documentation/imagecapturecore/icscannertransfermode?language=objc)
94// NS_ENUM
95#[repr(transparent)]
96#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
97pub struct ICScannerTransferMode(pub NSUInteger);
98impl ICScannerTransferMode {
99    #[doc(alias = "ICScannerTransferModeFileBased")]
100    pub const FileBased: Self = Self(0);
101    #[doc(alias = "ICScannerTransferModeMemoryBased")]
102    pub const MemoryBased: Self = Self(1);
103}
104
105unsafe impl Encode for ICScannerTransferMode {
106    const ENCODING: Encoding = NSUInteger::ENCODING;
107}
108
109unsafe impl RefEncode for ICScannerTransferMode {
110    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
111}
112
113extern_protocol!(
114    /// A delegate of ICScannerDevice must conform to ICScannerDeviceDelegate protocol.
115    ///
116    /// The ICScannerDeviceDelegate protocol inherits from the ICDeviceDelegate protocol.
117    ///
118    /// See also [Apple's documentation](https://developer.apple.com/documentation/imagecapturecore/icscannerdevicedelegate?language=objc)
119    #[cfg(feature = "ICDevice")]
120    pub unsafe trait ICScannerDeviceDelegate: ICDeviceDelegate {
121        /// This message is sent when another client closes an open session on the scanner.
122        ///
123        /// 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.
124        #[optional]
125        #[unsafe(method(scannerDeviceDidBecomeAvailable:))]
126        #[unsafe(method_family = none)]
127        unsafe fn scannerDeviceDidBecomeAvailable(&self, scanner: &ICScannerDevice);
128
129        #[cfg(feature = "ICScannerFunctionalUnits")]
130        /// This message is sent when a functional unit is selected on the scanner device.
131        ///
132        /// A functional unit is selected immediately after the scanner device is instantiated and in response to "requestSelectFunctionalUnit:" message.
133        #[optional]
134        #[unsafe(method(scannerDevice:didSelectFunctionalUnit:error:))]
135        #[unsafe(method_family = none)]
136        unsafe fn scannerDevice_didSelectFunctionalUnit_error(
137            &self,
138            scanner: &ICScannerDevice,
139            functional_unit: &ICScannerFunctionalUnit,
140            error: Option<&NSError>,
141        );
142
143        /// 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.
144        ///
145        /// This method has been deprecated and superceded by the didScanToURL: method for file based transfer, along with the didScanToBandData: for memory based transfer.
146        #[deprecated = "Use didScanToURL: for file URLs and didScanToBandData: for memory based transfers"]
147        #[optional]
148        #[unsafe(method(scannerDevice:didScanToURL:data:))]
149        #[unsafe(method_family = none)]
150        unsafe fn scannerDevice_didScanToURL_data(
151            &self,
152            scanner: &ICScannerDevice,
153            url: &NSURL,
154            data: &NSData,
155        );
156
157        /// 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.
158        ///
159        /// 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.
160        #[optional]
161        #[unsafe(method(scannerDevice:didScanToURL:))]
162        #[unsafe(method_family = none)]
163        unsafe fn scannerDevice_didScanToURL(&self, scanner: &ICScannerDevice, url: &NSURL);
164
165        #[cfg(feature = "ICScannerBandData")]
166        /// 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.
167        ///
168        /// In memory transfer mode, this will send a band of size that has been selected by the client via the maxMemoryBandSize property.
169        #[optional]
170        #[unsafe(method(scannerDevice:didScanToBandData:))]
171        #[unsafe(method_family = none)]
172        unsafe fn scannerDevice_didScanToBandData(
173            &self,
174            scanner: &ICScannerDevice,
175            data: &ICScannerBandData,
176        );
177
178        /// This message is sent after the scanner device completes an overview scan.
179        ///
180        /// This message is sent after the scanner device completes an overview scan.
181        #[optional]
182        #[unsafe(method(scannerDevice:didCompleteOverviewScanWithError:))]
183        #[unsafe(method_family = none)]
184        unsafe fn scannerDevice_didCompleteOverviewScanWithError(
185            &self,
186            scanner: &ICScannerDevice,
187            error: Option<&NSError>,
188        );
189
190        /// This message is sent after the scanner device completes a scan.
191        ///
192        /// This message is sent after the scanner device completes a scan.
193        #[optional]
194        #[unsafe(method(scannerDevice:didCompleteScanWithError:))]
195        #[unsafe(method_family = none)]
196        unsafe fn scannerDevice_didCompleteScanWithError(
197            &self,
198            scanner: &ICScannerDevice,
199            error: Option<&NSError>,
200        );
201    }
202);
203
204extern_class!(
205    /// ICScannerDevice is a concrete subclass of ICDevice class. ICDeviceBrowser creates instances of this class.
206    ///
207    /// 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.
208    ///
209    /// See also [Apple's documentation](https://developer.apple.com/documentation/imagecapturecore/icscannerdevice?language=objc)
210    #[unsafe(super(ICDevice, NSObject))]
211    #[derive(Debug, PartialEq, Eq, Hash)]
212    #[cfg(feature = "ICDevice")]
213    pub struct ICScannerDevice;
214);
215
216#[cfg(feature = "ICDevice")]
217extern_conformance!(
218    unsafe impl NSObjectProtocol for ICScannerDevice {}
219);
220
221#[cfg(feature = "ICDevice")]
222impl ICScannerDevice {
223    extern_methods!(
224        /// An array of functional unit types available on this scanner device. This is an array of NSNumber objects whose values are of type ICScannerFunctionalUnitType.
225        #[unsafe(method(availableFunctionalUnitTypes))]
226        #[unsafe(method_family = none)]
227        pub unsafe fn availableFunctionalUnitTypes(&self) -> Retained<NSArray<NSNumber>>;
228
229        #[cfg(feature = "ICScannerFunctionalUnits")]
230        /// The currently selected functional unit on the scanner device.
231        #[unsafe(method(selectedFunctionalUnit))]
232        #[unsafe(method_family = none)]
233        pub unsafe fn selectedFunctionalUnit(&self) -> Retained<ICScannerFunctionalUnit>;
234
235        /// The transfer mode for scanned document.
236        #[unsafe(method(transferMode))]
237        #[unsafe(method_family = none)]
238        pub unsafe fn transferMode(&self) -> ICScannerTransferMode;
239
240        /// Setter for [`transferMode`][Self::transferMode].
241        #[unsafe(method(setTransferMode:))]
242        #[unsafe(method_family = none)]
243        pub unsafe fn setTransferMode(&self, transfer_mode: ICScannerTransferMode);
244
245        /// The total maximum band size requested when performing a ICScannerTransferModeMemoryBased.
246        #[unsafe(method(maxMemoryBandSize))]
247        #[unsafe(method_family = none)]
248        pub unsafe fn maxMemoryBandSize(&self) -> u32;
249
250        /// Setter for [`maxMemoryBandSize`][Self::maxMemoryBandSize].
251        #[unsafe(method(setMaxMemoryBandSize:))]
252        #[unsafe(method_family = none)]
253        pub unsafe fn setMaxMemoryBandSize(&self, max_memory_band_size: u32);
254
255        /// The downloads directory.
256        #[unsafe(method(downloadsDirectory))]
257        #[unsafe(method_family = none)]
258        pub unsafe fn downloadsDirectory(&self) -> Retained<NSURL>;
259
260        /// Setter for [`downloadsDirectory`][Self::downloadsDirectory].
261        #[unsafe(method(setDownloadsDirectory:))]
262        #[unsafe(method_family = none)]
263        pub unsafe fn setDownloadsDirectory(&self, downloads_directory: &NSURL);
264
265        /// The document name.
266        #[unsafe(method(documentName))]
267        #[unsafe(method_family = none)]
268        pub unsafe fn documentName(&self) -> Retained<NSString>;
269
270        /// Setter for [`documentName`][Self::documentName].
271        ///
272        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
273        #[unsafe(method(setDocumentName:))]
274        #[unsafe(method_family = none)]
275        pub unsafe fn setDocumentName(&self, document_name: &NSString);
276
277        /// The document UTI. Currently supported UTIs are: kUTTypeJPEG, kUTTypeJPEG2000, kUTTypeTIFF, kUTTypePNG etc.
278        #[unsafe(method(documentUTI))]
279        #[unsafe(method_family = none)]
280        pub unsafe fn documentUTI(&self) -> Retained<NSString>;
281
282        /// Setter for [`documentUTI`][Self::documentUTI].
283        ///
284        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
285        #[unsafe(method(setDocumentUTI:))]
286        #[unsafe(method_family = none)]
287        pub unsafe fn setDocumentUTI(&self, document_uti: &NSString);
288
289        /// If the device is protected, instead of prompting the user for a username, this property
290        /// can be set to default to a specific username as a convience.  The value will persist until
291        /// reset by setting it to nil.
292        #[unsafe(method(defaultUsername))]
293        #[unsafe(method_family = none)]
294        pub unsafe fn defaultUsername(&self) -> Retained<NSString>;
295
296        /// Setter for [`defaultUsername`][Self::defaultUsername].
297        ///
298        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
299        #[unsafe(method(setDefaultUsername:))]
300        #[unsafe(method_family = none)]
301        pub unsafe fn setDefaultUsername(&self, default_username: &NSString);
302
303        /// This message requests to open a session on the protected device with the authorized username and
304        /// passcode.  If the device reports back a failure of credentials, they can be provided here for the
305        /// launch.
306        /// A client MUST open a session on a device in order to use the device.
307        ///
308        /// 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.
309        #[unsafe(method(requestOpenSessionWithCredentials:password:))]
310        #[unsafe(method_family = none)]
311        pub unsafe fn requestOpenSessionWithCredentials_password(
312            &self,
313            username: &NSString,
314            password: &NSString,
315        );
316
317        #[cfg(feature = "ICScannerFunctionalUnits")]
318        /// Requests the scanner device to select a functional unit.
319        ///
320        /// When this request is completed, the delegate will be notified using the 'scannerDevice:didSelectFunctionalUnit:error:' message.
321        #[unsafe(method(requestSelectFunctionalUnit:))]
322        #[unsafe(method_family = none)]
323        pub unsafe fn requestSelectFunctionalUnit(&self, r#type: ICScannerFunctionalUnitType);
324
325        /// Starts an overview scan on selectedFunctionalUnit.
326        ///
327        /// 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.
328        #[unsafe(method(requestOverviewScan))]
329        #[unsafe(method_family = none)]
330        pub unsafe fn requestOverviewScan(&self);
331
332        /// Starts a scan on selectedFunctionalUnit.
333        ///
334        /// 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.
335        #[unsafe(method(requestScan))]
336        #[unsafe(method_family = none)]
337        pub unsafe fn requestScan(&self);
338
339        /// Cancels the current scan operation started by sending a 'requestOverviewScan' or 'requestScan'.
340        #[unsafe(method(cancelScan))]
341        #[unsafe(method_family = none)]
342        pub unsafe fn cancelScan(&self);
343    );
344}
345
346/// Methods declared on superclass `NSObject`.
347#[cfg(feature = "ICDevice")]
348impl ICScannerDevice {
349    extern_methods!(
350        #[unsafe(method(init))]
351        #[unsafe(method_family = init)]
352        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
353
354        #[unsafe(method(new))]
355        #[unsafe(method_family = new)]
356        pub unsafe fn new() -> Retained<Self>;
357    );
358}