Skip to main content

ohos_basic_services_kit_sys/scan/
scan_ffi.rs

1// automatically generated by rust-bindgen 0.71.1
2
3#![allow(non_upper_case_globals)]
4#![allow(non_camel_case_types)]
5#![allow(non_snake_case)]
6
7#[cfg(feature = "api-12")]
8#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
9impl Scan_ErrorCode {
10    /// The operation is successful.
11    pub const SCAN_ERROR_NONE: Scan_ErrorCode = Scan_ErrorCode(0);
12    /// Permission verification failed.
13    pub const SCAN_ERROR_NO_PERMISSION: Scan_ErrorCode = Scan_ErrorCode(201);
14    /// The parameter is invalid. For example, the pointer is null or the character string is null.
15    pub const SCAN_ERROR_INVALID_PARAMETER: Scan_ErrorCode = Scan_ErrorCode(401);
16    /// General internal error.
17    pub const SCAN_ERROR_GENERIC_FAILURE: Scan_ErrorCode = Scan_ErrorCode(24300101);
18    /// RPC communication error.
19    pub const SCAN_ERROR_RPC_FAILURE: Scan_ErrorCode = Scan_ErrorCode(24300102);
20    /// Server error.
21    pub const SCAN_ERROR_SERVER_FAILURE: Scan_ErrorCode = Scan_ErrorCode(24300103);
22    /// Operation is not supported.
23    pub const SCAN_ERROR_UNSUPPORTED: Scan_ErrorCode = Scan_ErrorCode(24300104);
24    /// Operation was cancelled.
25    pub const SCAN_ERROR_CANCELED: Scan_ErrorCode = Scan_ErrorCode(24300105);
26    /// Device is busy, try again later.
27    pub const SCAN_ERROR_DEVICE_BUSY: Scan_ErrorCode = Scan_ErrorCode(24300106);
28    /// Data is invalid (includes no dev at open).
29    pub const SCAN_ERROR_INVALID: Scan_ErrorCode = Scan_ErrorCode(24300107);
30    /// Document feeder jammed.
31    pub const SCAN_ERROR_JAMMED: Scan_ErrorCode = Scan_ErrorCode(24300108);
32    /// Document feeder out of documents.
33    pub const SCAN_ERROR_NO_DOCS: Scan_ErrorCode = Scan_ErrorCode(24300109);
34    /// Scanner cover is open.
35    pub const SCAN_ERROR_COVER_OPEN: Scan_ErrorCode = Scan_ErrorCode(24300110);
36    /// Error during device I/O.
37    pub const SCAN_ERROR_IO_ERROR: Scan_ErrorCode = Scan_ErrorCode(24300111);
38    /// Out of memory.
39    pub const SCAN_ERROR_NO_MEMORY: Scan_ErrorCode = Scan_ErrorCode(24300112);
40}
41#[repr(transparent)]
42/// Defines error codes.
43///
44///
45/// Available since API-level: 12
46///
47/// Version: 1.0
48#[cfg(feature = "api-12")]
49#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
50#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
51pub struct Scan_ErrorCode(pub ::core::ffi::c_uint);
52/// Indicates scanner device information.
53///
54///
55/// Available since API-level: 12
56#[cfg(feature = "api-12")]
57#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
58#[repr(C)]
59#[derive(Debug, Copy, Clone)]
60pub struct Scan_ScannerDevice {
61    /// Scanner id.
62    pub scannerId: *const ::core::ffi::c_char,
63    /// Scanner manufacturer.
64    pub manufacturer: *const ::core::ffi::c_char,
65    /// Scanner model.
66    pub model: *const ::core::ffi::c_char,
67    /// Scanner discoverMode.
68    pub discoverMode: *const ::core::ffi::c_char,
69    /// Scanner serialNumber.
70    pub serialNumber: *const ::core::ffi::c_char,
71}
72/// Indicates the progress of scanning a picture by the scanner.
73///
74///
75/// Available since API-level: 12
76#[cfg(feature = "api-12")]
77#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
78#[repr(C)]
79#[derive(Debug, Copy, Clone)]
80pub struct Scan_PictureScanProgress {
81    /// Picture progress from 0 to 100.
82    pub progress: i32,
83    /// scanner file handle.
84    pub fd: i32,
85    /// Indicates whether the image is the last scanned image.
86    pub isFinal: bool,
87}
88/// Indicates all parameter options for one scanner.
89///
90///
91/// Available since API-level: 12
92#[cfg(feature = "api-12")]
93#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
94#[repr(C)]
95#[derive(Debug, Copy, Clone)]
96pub struct Scan_ScannerOptions {
97    /// Title of an option.
98    pub titles: *mut *mut ::core::ffi::c_char,
99    /// Description of an option.
100    pub descriptions: *mut *mut ::core::ffi::c_char,
101    /// The range that an option can be set to.
102    pub ranges: *mut *mut ::core::ffi::c_char,
103    /// Number of parameter options that can be set.
104    pub optionCount: i32,
105}
106/// Scanner devices discovery callback, register by [`OH_Scan_StartScannerDiscovery`].
107/// The memory to which the pointer points will be released when the callback function ends.
108///
109/// # Arguments
110///
111/// * `devices` - List of all discovered scanner devices.
112///
113/// * `deviceCount` - Number of Scanners Found.
114///
115/// Available since API-level: 12
116#[cfg(feature = "api-12")]
117#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
118pub type Scan_ScannerDiscoveryCallback = ::core::option::Option<
119    unsafe extern "C" fn(devices: *mut *mut Scan_ScannerDevice, deviceCount: i32),
120>;
121extern "C" {
122    /// This API checks and pulls up the scan service, initializes the scan client,
123    /// and establishes a connection to the scan service.
124    ///
125    /// `ohos.permission.PRINT`
126    ///
127    /// # Returns
128    ///
129    /// * [`Scan_ERROR_NONE`] Indicates the scanning service is successfully started.
130    /// [`SCAN_ERROR_NO_PERMISSION`] Indicates have no permission to use this interface.
131    /// [`SCAN_ERROR_RPC_FAILURE`] Indicates an RPC communication error.
132    /// [`SCAN_ERROR_SERVER_FAILURE`] Indicates An error occurs in the scan process.
133    ///
134    /// Required System Capabilities: SystemCapability.Print.PrintFramework
135    ///
136    /// Available since API-level: 12
137    #[cfg(feature = "api-12")]
138    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
139    pub fn OH_Scan_Init() -> i32;
140    /// This API starts discovering scanners, Register a callback to handle discovered scanner devices.
141    ///
142    /// `ohos.permission.PRINT`
143    /// # Arguments
144    ///
145    /// * `callback` - The [`Scan_ScannerDiscoveryCallback`] of scanner discovery event.
146    ///
147    /// # Returns
148    ///
149    /// * [`Scan_ERROR_NONE`] Indicates successful start of scanner search.
150    /// [`SCAN_ERROR_NO_PERMISSION`] Indicates have no permission to use this interface.
151    /// [`SCAN_ERROR_RPC_FAILURE`] Indicates an RPC communication error.
152    /// [`SCAN_ERROR_SERVER_FAILURE`] Indicates An error occurs in the scan process.
153    ///
154    /// Required System Capabilities: SystemCapability.Print.PrintFramework
155    ///
156    /// Available since API-level: 12
157    #[cfg(feature = "api-12")]
158    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
159    pub fn OH_Scan_StartScannerDiscovery(callback: Scan_ScannerDiscoveryCallback) -> i32;
160    /// This API connects to scanner devices.
161    ///
162    /// `ohos.permission.PRINT`
163    /// # Arguments
164    ///
165    /// * `scannerId` - The id used to connect to the scanner.
166    ///
167    /// # Returns
168    ///
169    /// * [`Scan_ERROR_NONE`] Indicates that the scanner was successfully connected.
170    /// [`SCAN_ERROR_NO_PERMISSION`] Indicates have no permission to use this interface.
171    /// [`SCAN_ERROR_RPC_FAILURE`] Indicates an RPC communication error.
172    /// [`SCAN_ERROR_SERVER_FAILURE`] Indicates An error occurs in the scan process.
173    /// [`SCAN_ERROR_DEVICE_BUSY`] Indicates that the scanner is busy.
174    /// [`SCAN_ERROR_INVALID_PARAMETER`] Indicates that the input parameter is invalid.
175    /// [`SCAN_ERROR_IO_ERROR`] Indicates an error occured while communicating with the device.
176    /// [`SCAN_ERROR_NO_MEMORY`] Indicates an insufficent amount of memory is available.
177    ///
178    /// Required System Capabilities: SystemCapability.Print.PrintFramework
179    ///
180    /// Available since API-level: 12
181    #[cfg(feature = "api-12")]
182    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
183    pub fn OH_Scan_OpenScanner(scannerId: *const ::core::ffi::c_char) -> i32;
184    /// This API is used to close the connected scanner device.
185    ///
186    /// `ohos.permission.PRINT`
187    /// # Arguments
188    ///
189    /// * `scannerId` - The id to disconnect the scanner.
190    ///
191    /// # Returns
192    ///
193    /// * [`Scan_ERROR_NONE`] Indicates that the scanner connection was successfully closed.
194    /// [`SCAN_ERROR_NO_PERMISSION`] Indicates have no permission to use this interface.
195    /// [`SCAN_ERROR_RPC_FAILURE`] Indicates an RPC communication error.
196    /// [`SCAN_ERROR_SERVER_FAILURE`] Indicates An error occurs in the scan process.
197    /// [`SCAN_ERROR_INVALID_PARAMETER`] Indicates that the input parameter is invalid.
198    ///
199    /// Required System Capabilities: SystemCapability.Print.PrintFramework
200    ///
201    /// Available since API-level: 12
202    #[cfg(feature = "api-12")]
203    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
204    pub fn OH_Scan_CloseScanner(scannerId: *const ::core::ffi::c_char) -> i32;
205    /// This API can be used to get a list of options that can be set by the scanner.
206    /// The returned struct pointer points to memory that is automatically freed when [`OH_Scan_Exit`],
207    /// and only one copy will be stored in memory for each model.
208    ///
209    /// `ohos.permission.PRINT`
210    /// # Arguments
211    ///
212    /// * `scannerId` - The id used to obtain the scanner parameters.
213    ///
214    /// * `errorCode` - The errorCode returns [`Scan_ErrorCode#Scan_ERROR_NONE`] if the execution is successful,
215    /// otherwise returns a specific error code, refer to [`Print_ErrorCode`].
216    ///
217    /// # Returns
218    ///
219    /// * [`Scan_ERROR_NONE`] Indicates that the scanner parameter options are successfully obtained.
220    /// [`SCAN_ERROR_NO_PERMISSION`] Indicates have no permission to use this interface.
221    /// [`SCAN_ERROR_RPC_FAILURE`] Indicates an RPC communication error.
222    /// [`SCAN_ERROR_SERVER_FAILURE`] Indicates An error occurs in the scan process.
223    /// [`SCAN_ERROR_INVALID_PARAMETER`] Indicates invalid parameter.
224    ///
225    /// Required System Capabilities: SystemCapability.Print.PrintFramework
226    ///
227    /// Available since API-level: 12
228    #[cfg(feature = "api-12")]
229    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
230    pub fn OH_Scan_GetScannerParameter(
231        scannerId: *const ::core::ffi::c_char,
232        errorCode: *mut i32,
233    ) -> *mut Scan_ScannerOptions;
234    /// This API can be used to set one of the scanner's option parameters.
235    /// The option and value passed in are obtained from [`OH_Scan_GetScannerParameter`].
236    ///
237    /// `ohos.permission.PRINT`
238    /// # Arguments
239    ///
240    /// * `scannerId` - This id is used to set the options for a specific scanner.
241    ///
242    /// * `option` - Options number to be set.The value ranges from 0 to [`optionCount`] - 1,
243    /// be obtained from the [`Scan_ScannerOptions`].
244    ///
245    /// * `value` - Option value to be set, valid value is obtained from the [`ranges`],
246    /// be obtained from the [`Scan_ScannerOptions`].
247    ///
248    /// # Returns
249    ///
250    /// * [`Scan_ERROR_NONE`] Indicates that the scanner parameters were successfully set.
251    /// [`SCAN_ERROR_NO_PERMISSION`] Indicates have no permission to use this interface.
252    /// [`SCAN_ERROR_RPC_FAILURE`] Indicates an RPC communication error.
253    /// [`SCAN_ERROR_SERVER_FAILURE`] Indicates an error occurs in the scan process.
254    /// [`SCAN_ERROR_INVALID_PARAMETER`] Indicates invalid parameter.
255    ///
256    /// Required System Capabilities: SystemCapability.Print.PrintFramework
257    ///
258    /// Available since API-level: 12
259    #[cfg(feature = "api-12")]
260    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
261    pub fn OH_Scan_SetScannerParameter(
262        scannerId: *const ::core::ffi::c_char,
263        option: i32,
264        value: *const ::core::ffi::c_char,
265    ) -> i32;
266    /// This API allows the scanner to start scanning.
267    ///
268    /// `ohos.permission.PRINT`
269    /// # Arguments
270    ///
271    /// * `scannerId` - This id is used to start the scan job for the specified scanner.
272    ///
273    /// * `batchMode` - Whether to start the scanner in batch mode.
274    ///
275    /// # Returns
276    ///
277    /// * [`Scan_ERROR_NONE`] Indicates that the scanner has successfully canceled the scan job.
278    /// [`SCAN_ERROR_NO_PERMISSION`] Indicates have no permission to use this interface.
279    /// [`SCAN_ERROR_RPC_FAILURE`] Indicates an RPC communication error.
280    /// [`SCAN_ERROR_SERVER_FAILURE`] Indicates An error occurs in the scan process.
281    /// [`SCAN_ERROR_JAMMED`] Indicates the document feeder is jammed.
282    /// [`SCAN_ERROR_NO_DOCS`] Indicates the document feeder is out of documents.
283    /// [`SCAN_ERROR_COVER_OPEN`] Indicates the scanner cover is open.
284    /// [`SCAN_ERROR_IO_ERROR`] Indicates an error occurred while communicating with the device.
285    /// [`SCAN_ERROR_NO_MEMORY`] Indicates an insufficent amount of memory is available.
286    /// [`SCAN_ERROR_INVALID_PARAMETER`] Indicates that the input parameter is invalid.
287    /// [`SCAN_ERROR_DEVICE_BUSY`] Indicates the device is busy, the operation should be retried later.
288    ///
289    /// Required System Capabilities: SystemCapability.Print.PrintFramework
290    ///
291    /// Available since API-level: 12
292    #[cfg(feature = "api-12")]
293    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
294    pub fn OH_Scan_StartScan(scannerId: *const ::core::ffi::c_char, batchMode: bool) -> i32;
295    /// This API allows the scanner to cancel the scan.
296    ///
297    /// `ohos.permission.PRINT`
298    /// # Arguments
299    ///
300    /// * `scannerId` - This id is used to cancel the scan job for the specified scanner.
301    ///
302    /// # Returns
303    ///
304    /// * [`Scan_ERROR_NONE`] Indicates that the scanner has successfully canceled the scan job.
305    /// [`SCAN_ERROR_NO_PERMISSION`] Indicates have no permission to use this interface.
306    /// [`SCAN_ERROR_INVALID_PARAMETER`] Indicates if the pointer is null or the character string is null.
307    /// [`SCAN_ERROR_RPC_FAILURE`] Indicates an RPC communication error.
308    /// [`SCAN_ERROR_SERVER_FAILURE`] Indicates An error occurs in the scan process.
309    ///
310    /// Required System Capabilities: SystemCapability.Print.PrintFramework
311    ///
312    /// Available since API-level: 12
313    #[cfg(feature = "api-12")]
314    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
315    pub fn OH_Scan_CancelScan(scannerId: *const ::core::ffi::c_char) -> i32;
316    /// This API can get the progress of the scanner scanning the picture.A non-null value must be passed in,
317    /// and the scan progress will be written to the structure to which the pointer points.
318    ///
319    /// `ohos.permission.PRINT`
320    /// # Arguments
321    ///
322    /// * `scannerId` - The id for querying the image scanning progress of the scanner.
323    ///
324    /// * `prog` - The [`Scan_PictureScanProgress`] of scanning pictures, must be a non-null value.
325    ///
326    /// # Returns
327    ///
328    /// * [`Scan_ERROR_NONE`] Indicates the scanner has successfully queried the progress of the scanned image.
329    /// [`SCAN_ERROR_NO_PERMISSION`] Indicates have no permission to use this interface.
330    /// [`SCAN_ERROR_INVALID_PARAMETER`] Indicates if the pointer is null or the character string is null.
331    /// [`SCAN_ERROR_RPC_FAILURE`] Indicates an RPC communication error.
332    /// [`SCAN_ERROR_SERVER_FAILURE`] Indicates An error occurs in the scan process.
333    /// [`SCAN_ERROR_JAMMED`] Indicates the document feeder is jammed.
334    /// [`SCAN_ERROR_NO_DOCS`] Indicates the document feeder is out of documents.
335    /// [`SCAN_ERROR_COVER_OPEN`] Indicates the scanner cover is open.
336    /// [`SCAN_ERROR_IO_ERROR`] Indicates an error occurred while communicating with the scanner.
337    /// [`SCAN_ERROR_NO_MEMORY`] Indicates an insufficent amount of memory is available.
338    /// [`SCAN_ERROR_DEVICE_BUSY`] Indicates the device is busy, the operation should be retried later.
339    ///
340    /// Required System Capabilities: SystemCapability.Print.PrintFramework
341    ///
342    /// Available since API-level: 12
343    #[cfg(feature = "api-12")]
344    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
345    pub fn OH_Scan_GetPictureScanProgress(
346        scannerId: *const ::core::ffi::c_char,
347        prog: *mut Scan_PictureScanProgress,
348    ) -> i32;
349    /// This API can be used to exit the scanning service, free the Scan Framework Memory,
350    /// and unregister the callback for scanner discover.
351    ///
352    /// `ohos.permission.PRINT`
353    ///
354    /// # Returns
355    ///
356    /// * [`Scan_ERROR_NONE`] Indicates the scan service exit successfully.
357    /// [`SCAN_ERROR_NO_PERMISSION`] Indicates have no permission to use this interface.
358    /// [`SCAN_ERROR_RPC_FAILURE`] Indicates an RPC communication error.
359    /// [`SCAN_ERROR_SERVER_FAILURE`] Indicates An error occurs in the scan process.
360    ///
361    /// Required System Capabilities: SystemCapability.Print.PrintFramework
362    ///
363    /// Available since API-level: 12
364    #[cfg(feature = "api-12")]
365    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
366    pub fn OH_Scan_Exit() -> i32;
367}