1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
//! 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>;
);
}