ohos-basic-services-kit-sys 0.1.0

Raw bindings to the BasicServicesKit NDK of OpenHarmony
Documentation
// 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;
}