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
359
360
361
362
363
364
365
366
367
// automatically generated by rust-bindgen 0.71.1
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
impl Scan_ErrorCode {
/// The operation is successful.
pub const SCAN_ERROR_NONE: Scan_ErrorCode = Scan_ErrorCode(0);
/// Permission verification failed.
pub const SCAN_ERROR_NO_PERMISSION: Scan_ErrorCode = Scan_ErrorCode(201);
/// The parameter is invalid. For example, the pointer is null or the character string is null.
pub const SCAN_ERROR_INVALID_PARAMETER: Scan_ErrorCode = Scan_ErrorCode(401);
/// General internal error.
pub const SCAN_ERROR_GENERIC_FAILURE: Scan_ErrorCode = Scan_ErrorCode(24300101);
/// RPC communication error.
pub const SCAN_ERROR_RPC_FAILURE: Scan_ErrorCode = Scan_ErrorCode(24300102);
/// Server error.
pub const SCAN_ERROR_SERVER_FAILURE: Scan_ErrorCode = Scan_ErrorCode(24300103);
/// Operation is not supported.
pub const SCAN_ERROR_UNSUPPORTED: Scan_ErrorCode = Scan_ErrorCode(24300104);
/// Operation was cancelled.
pub const SCAN_ERROR_CANCELED: Scan_ErrorCode = Scan_ErrorCode(24300105);
/// Device is busy, try again later.
pub const SCAN_ERROR_DEVICE_BUSY: Scan_ErrorCode = Scan_ErrorCode(24300106);
/// Data is invalid (includes no dev at open).
pub const SCAN_ERROR_INVALID: Scan_ErrorCode = Scan_ErrorCode(24300107);
/// Document feeder jammed.
pub const SCAN_ERROR_JAMMED: Scan_ErrorCode = Scan_ErrorCode(24300108);
/// Document feeder out of documents.
pub const SCAN_ERROR_NO_DOCS: Scan_ErrorCode = Scan_ErrorCode(24300109);
/// Scanner cover is open.
pub const SCAN_ERROR_COVER_OPEN: Scan_ErrorCode = Scan_ErrorCode(24300110);
/// Error during device I/O.
pub const SCAN_ERROR_IO_ERROR: Scan_ErrorCode = Scan_ErrorCode(24300111);
/// Out of memory.
pub const SCAN_ERROR_NO_MEMORY: Scan_ErrorCode = Scan_ErrorCode(24300112);
}
#[repr(transparent)]
/// Defines error codes.
///
///
/// Available since API-level: 12
///
/// Version: 1.0
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Scan_ErrorCode(pub ::core::ffi::c_uint);
/// Indicates scanner device information.
///
///
/// Available since API-level: 12
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct Scan_ScannerDevice {
/// Scanner id.
pub scannerId: *const ::core::ffi::c_char,
/// Scanner manufacturer.
pub manufacturer: *const ::core::ffi::c_char,
/// Scanner model.
pub model: *const ::core::ffi::c_char,
/// Scanner discoverMode.
pub discoverMode: *const ::core::ffi::c_char,
/// Scanner serialNumber.
pub serialNumber: *const ::core::ffi::c_char,
}
/// Indicates the progress of scanning a picture by the scanner.
///
///
/// Available since API-level: 12
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct Scan_PictureScanProgress {
/// Picture progress from 0 to 100.
pub progress: i32,
/// scanner file handle.
pub fd: i32,
/// Indicates whether the image is the last scanned image.
pub isFinal: bool,
}
/// Indicates all parameter options for one scanner.
///
///
/// Available since API-level: 12
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct Scan_ScannerOptions {
/// Title of an option.
pub titles: *mut *mut ::core::ffi::c_char,
/// Description of an option.
pub descriptions: *mut *mut ::core::ffi::c_char,
/// The range that an option can be set to.
pub ranges: *mut *mut ::core::ffi::c_char,
/// Number of parameter options that can be set.
pub optionCount: i32,
}
/// Scanner devices discovery callback, register by [`OH_Scan_StartScannerDiscovery`].
/// The memory to which the pointer points will be released when the callback function ends.
///
/// # Arguments
///
/// * `devices` - List of all discovered scanner devices.
///
/// * `deviceCount` - Number of Scanners Found.
///
/// Available since API-level: 12
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
pub type Scan_ScannerDiscoveryCallback = ::core::option::Option<
unsafe extern "C" fn(devices: *mut *mut Scan_ScannerDevice, deviceCount: i32),
>;
extern "C" {
/// This API checks and pulls up the scan service, initializes the scan client,
/// and establishes a connection to the scan service.
///
/// `ohos.permission.PRINT`
///
/// # Returns
///
/// * [`Scan_ERROR_NONE`] Indicates the scanning service is successfully started.
/// [`SCAN_ERROR_NO_PERMISSION`] Indicates have no permission to use this interface.
/// [`SCAN_ERROR_RPC_FAILURE`] Indicates an RPC communication error.
/// [`SCAN_ERROR_SERVER_FAILURE`] Indicates An error occurs in the scan process.
///
/// Required System Capabilities: SystemCapability.Print.PrintFramework
///
/// Available since API-level: 12
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
pub fn OH_Scan_Init() -> i32;
/// This API starts discovering scanners, Register a callback to handle discovered scanner devices.
///
/// `ohos.permission.PRINT`
/// # Arguments
///
/// * `callback` - The [`Scan_ScannerDiscoveryCallback`] of scanner discovery event.
///
/// # Returns
///
/// * [`Scan_ERROR_NONE`] Indicates successful start of scanner search.
/// [`SCAN_ERROR_NO_PERMISSION`] Indicates have no permission to use this interface.
/// [`SCAN_ERROR_RPC_FAILURE`] Indicates an RPC communication error.
/// [`SCAN_ERROR_SERVER_FAILURE`] Indicates An error occurs in the scan process.
///
/// Required System Capabilities: SystemCapability.Print.PrintFramework
///
/// Available since API-level: 12
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
pub fn OH_Scan_StartScannerDiscovery(callback: Scan_ScannerDiscoveryCallback) -> i32;
/// This API connects to scanner devices.
///
/// `ohos.permission.PRINT`
/// # Arguments
///
/// * `scannerId` - The id used to connect to the scanner.
///
/// # Returns
///
/// * [`Scan_ERROR_NONE`] Indicates that the scanner was successfully connected.
/// [`SCAN_ERROR_NO_PERMISSION`] Indicates have no permission to use this interface.
/// [`SCAN_ERROR_RPC_FAILURE`] Indicates an RPC communication error.
/// [`SCAN_ERROR_SERVER_FAILURE`] Indicates An error occurs in the scan process.
/// [`SCAN_ERROR_DEVICE_BUSY`] Indicates that the scanner is busy.
/// [`SCAN_ERROR_INVALID_PARAMETER`] Indicates that the input parameter is invalid.
/// [`SCAN_ERROR_IO_ERROR`] Indicates an error occured while communicating with the device.
/// [`SCAN_ERROR_NO_MEMORY`] Indicates an insufficent amount of memory is available.
///
/// Required System Capabilities: SystemCapability.Print.PrintFramework
///
/// Available since API-level: 12
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
pub fn OH_Scan_OpenScanner(scannerId: *const ::core::ffi::c_char) -> i32;
/// This API is used to close the connected scanner device.
///
/// `ohos.permission.PRINT`
/// # Arguments
///
/// * `scannerId` - The id to disconnect the scanner.
///
/// # Returns
///
/// * [`Scan_ERROR_NONE`] Indicates that the scanner connection was successfully closed.
/// [`SCAN_ERROR_NO_PERMISSION`] Indicates have no permission to use this interface.
/// [`SCAN_ERROR_RPC_FAILURE`] Indicates an RPC communication error.
/// [`SCAN_ERROR_SERVER_FAILURE`] Indicates An error occurs in the scan process.
/// [`SCAN_ERROR_INVALID_PARAMETER`] Indicates that the input parameter is invalid.
///
/// Required System Capabilities: SystemCapability.Print.PrintFramework
///
/// Available since API-level: 12
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
pub fn OH_Scan_CloseScanner(scannerId: *const ::core::ffi::c_char) -> i32;
/// This API can be used to get a list of options that can be set by the scanner.
/// The returned struct pointer points to memory that is automatically freed when [`OH_Scan_Exit`],
/// and only one copy will be stored in memory for each model.
///
/// `ohos.permission.PRINT`
/// # Arguments
///
/// * `scannerId` - The id used to obtain the scanner parameters.
///
/// * `errorCode` - The errorCode returns [`Scan_ErrorCode#Scan_ERROR_NONE`] if the execution is successful,
/// otherwise returns a specific error code, refer to [`Print_ErrorCode`].
///
/// # Returns
///
/// * [`Scan_ERROR_NONE`] Indicates that the scanner parameter options are successfully obtained.
/// [`SCAN_ERROR_NO_PERMISSION`] Indicates have no permission to use this interface.
/// [`SCAN_ERROR_RPC_FAILURE`] Indicates an RPC communication error.
/// [`SCAN_ERROR_SERVER_FAILURE`] Indicates An error occurs in the scan process.
/// [`SCAN_ERROR_INVALID_PARAMETER`] Indicates invalid parameter.
///
/// Required System Capabilities: SystemCapability.Print.PrintFramework
///
/// Available since API-level: 12
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
pub fn OH_Scan_GetScannerParameter(
scannerId: *const ::core::ffi::c_char,
errorCode: *mut i32,
) -> *mut Scan_ScannerOptions;
/// This API can be used to set one of the scanner's option parameters.
/// The option and value passed in are obtained from [`OH_Scan_GetScannerParameter`].
///
/// `ohos.permission.PRINT`
/// # Arguments
///
/// * `scannerId` - This id is used to set the options for a specific scanner.
///
/// * `option` - Options number to be set.The value ranges from 0 to [`optionCount`] - 1,
/// be obtained from the [`Scan_ScannerOptions`].
///
/// * `value` - Option value to be set, valid value is obtained from the [`ranges`],
/// be obtained from the [`Scan_ScannerOptions`].
///
/// # Returns
///
/// * [`Scan_ERROR_NONE`] Indicates that the scanner parameters were successfully set.
/// [`SCAN_ERROR_NO_PERMISSION`] Indicates have no permission to use this interface.
/// [`SCAN_ERROR_RPC_FAILURE`] Indicates an RPC communication error.
/// [`SCAN_ERROR_SERVER_FAILURE`] Indicates an error occurs in the scan process.
/// [`SCAN_ERROR_INVALID_PARAMETER`] Indicates invalid parameter.
///
/// Required System Capabilities: SystemCapability.Print.PrintFramework
///
/// Available since API-level: 12
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
pub fn OH_Scan_SetScannerParameter(
scannerId: *const ::core::ffi::c_char,
option: i32,
value: *const ::core::ffi::c_char,
) -> i32;
/// This API allows the scanner to start scanning.
///
/// `ohos.permission.PRINT`
/// # Arguments
///
/// * `scannerId` - This id is used to start the scan job for the specified scanner.
///
/// * `batchMode` - Whether to start the scanner in batch mode.
///
/// # Returns
///
/// * [`Scan_ERROR_NONE`] Indicates that the scanner has successfully canceled the scan job.
/// [`SCAN_ERROR_NO_PERMISSION`] Indicates have no permission to use this interface.
/// [`SCAN_ERROR_RPC_FAILURE`] Indicates an RPC communication error.
/// [`SCAN_ERROR_SERVER_FAILURE`] Indicates An error occurs in the scan process.
/// [`SCAN_ERROR_JAMMED`] Indicates the document feeder is jammed.
/// [`SCAN_ERROR_NO_DOCS`] Indicates the document feeder is out of documents.
/// [`SCAN_ERROR_COVER_OPEN`] Indicates the scanner cover is open.
/// [`SCAN_ERROR_IO_ERROR`] Indicates an error occurred while communicating with the device.
/// [`SCAN_ERROR_NO_MEMORY`] Indicates an insufficent amount of memory is available.
/// [`SCAN_ERROR_INVALID_PARAMETER`] Indicates that the input parameter is invalid.
/// [`SCAN_ERROR_DEVICE_BUSY`] Indicates the device is busy, the operation should be retried later.
///
/// Required System Capabilities: SystemCapability.Print.PrintFramework
///
/// Available since API-level: 12
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
pub fn OH_Scan_StartScan(scannerId: *const ::core::ffi::c_char, batchMode: bool) -> i32;
/// This API allows the scanner to cancel the scan.
///
/// `ohos.permission.PRINT`
/// # Arguments
///
/// * `scannerId` - This id is used to cancel the scan job for the specified scanner.
///
/// # Returns
///
/// * [`Scan_ERROR_NONE`] Indicates that the scanner has successfully canceled the scan job.
/// [`SCAN_ERROR_NO_PERMISSION`] Indicates have no permission to use this interface.
/// [`SCAN_ERROR_INVALID_PARAMETER`] Indicates if the pointer is null or the character string is null.
/// [`SCAN_ERROR_RPC_FAILURE`] Indicates an RPC communication error.
/// [`SCAN_ERROR_SERVER_FAILURE`] Indicates An error occurs in the scan process.
///
/// Required System Capabilities: SystemCapability.Print.PrintFramework
///
/// Available since API-level: 12
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
pub fn OH_Scan_CancelScan(scannerId: *const ::core::ffi::c_char) -> i32;
/// This API can get the progress of the scanner scanning the picture.A non-null value must be passed in,
/// and the scan progress will be written to the structure to which the pointer points.
///
/// `ohos.permission.PRINT`
/// # Arguments
///
/// * `scannerId` - The id for querying the image scanning progress of the scanner.
///
/// * `prog` - The [`Scan_PictureScanProgress`] of scanning pictures, must be a non-null value.
///
/// # Returns
///
/// * [`Scan_ERROR_NONE`] Indicates the scanner has successfully queried the progress of the scanned image.
/// [`SCAN_ERROR_NO_PERMISSION`] Indicates have no permission to use this interface.
/// [`SCAN_ERROR_INVALID_PARAMETER`] Indicates if the pointer is null or the character string is null.
/// [`SCAN_ERROR_RPC_FAILURE`] Indicates an RPC communication error.
/// [`SCAN_ERROR_SERVER_FAILURE`] Indicates An error occurs in the scan process.
/// [`SCAN_ERROR_JAMMED`] Indicates the document feeder is jammed.
/// [`SCAN_ERROR_NO_DOCS`] Indicates the document feeder is out of documents.
/// [`SCAN_ERROR_COVER_OPEN`] Indicates the scanner cover is open.
/// [`SCAN_ERROR_IO_ERROR`] Indicates an error occurred while communicating with the scanner.
/// [`SCAN_ERROR_NO_MEMORY`] Indicates an insufficent amount of memory is available.
/// [`SCAN_ERROR_DEVICE_BUSY`] Indicates the device is busy, the operation should be retried later.
///
/// Required System Capabilities: SystemCapability.Print.PrintFramework
///
/// Available since API-level: 12
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
pub fn OH_Scan_GetPictureScanProgress(
scannerId: *const ::core::ffi::c_char,
prog: *mut Scan_PictureScanProgress,
) -> i32;
/// This API can be used to exit the scanning service, free the Scan Framework Memory,
/// and unregister the callback for scanner discover.
///
/// `ohos.permission.PRINT`
///
/// # Returns
///
/// * [`Scan_ERROR_NONE`] Indicates the scan service exit successfully.
/// [`SCAN_ERROR_NO_PERMISSION`] Indicates have no permission to use this interface.
/// [`SCAN_ERROR_RPC_FAILURE`] Indicates an RPC communication error.
/// [`SCAN_ERROR_SERVER_FAILURE`] Indicates An error occurs in the scan process.
///
/// Required System Capabilities: SystemCapability.Print.PrintFramework
///
/// Available since API-level: 12
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
pub fn OH_Scan_Exit() -> i32;
}