From 6afd0e342344dbc0448eb47de787145171483905 Mon Sep 17 00:00:00 2001 From: sidit77 Date: Wed, 10 Jan 2024 23:29:39 +0100 Subject: [PATCH 1/4] switched to relative imports --- src/windows_native/descriptor/encoder.rs | 8 ++++---- src/windows_native/descriptor/mod.rs | 12 ++++++------ src/windows_native/descriptor/tests.rs | 2 +- src/windows_native/descriptor/typedefs.rs | 2 +- src/windows_native/dev_node.rs | 6 +++--- src/windows_native/device_info.rs | 12 ++++++------ src/windows_native/hid.rs | 4 ++-- src/windows_native/interfaces.rs | 8 ++++---- src/windows_native/mod.rs | 16 ++++++++-------- src/windows_native/string.rs | 2 +- src/windows_native/types.rs | 2 +- 11 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/windows_native/descriptor/encoder.rs b/src/windows_native/descriptor/encoder.rs index 74ae814..02d2d7e 100644 --- a/src/windows_native/descriptor/encoder.rs +++ b/src/windows_native/descriptor/encoder.rs @@ -1,7 +1,7 @@ -use crate::windows_native::descriptor::typedefs::{Caps, LinkCollectionNode}; -use crate::windows_native::descriptor::types::{ItemNodeType, Items, MainItemNode, MainItems}; -use crate::windows_native::error::{WinError, WinResult}; -use crate::windows_native::utils::PeakIterExt; +use super::typedefs::{Caps, LinkCollectionNode}; +use super::types::{ItemNodeType, Items, MainItemNode, MainItems}; +use super::super::error::{WinError, WinResult}; +use super::super::utils::PeakIterExt; pub fn encode_descriptor(main_item_list: &[MainItemNode], caps_list: &[Caps], link_collection_nodes: &[LinkCollectionNode]) -> WinResult> { // *********************************** diff --git a/src/windows_native/descriptor/mod.rs b/src/windows_native/descriptor/mod.rs index 87974f6..5f236d3 100644 --- a/src/windows_native/descriptor/mod.rs +++ b/src/windows_native/descriptor/mod.rs @@ -9,12 +9,12 @@ use std::collections::HashMap; use std::ffi::c_void; use std::slice; use crate::ensure; -use crate::windows_native::descriptor::encoder::encode_descriptor; -use crate::windows_native::descriptor::typedefs::{Caps, HidpPreparsedData, LinkCollectionNode}; -use crate::windows_native::descriptor::types::{BitRange, ItemNodeType, MainItemNode, MainItems, ReportType}; -use crate::windows_native::error::{WinError, WinResult}; -use crate::windows_native::hid::PreparsedData; -use crate::windows_native::utils::PeakIterExt; +use encoder::encode_descriptor; +use typedefs::{Caps, HidpPreparsedData, LinkCollectionNode}; +use types::{BitRange, ItemNodeType, MainItemNode, MainItems, ReportType}; +use super::error::{WinError, WinResult}; +use super::hid::PreparsedData; +use super::utils::PeakIterExt; pub fn get_descriptor(pp_data: &PreparsedData) -> WinResult> { diff --git a/src/windows_native/descriptor/tests.rs b/src/windows_native/descriptor/tests.rs index b39dfb3..b3f83de 100644 --- a/src/windows_native/descriptor/tests.rs +++ b/src/windows_native/descriptor/tests.rs @@ -1,5 +1,5 @@ use std::fs::read_to_string; -use crate::windows_native::descriptor::get_descriptor_ptr; +use super::get_descriptor_ptr; #[test] fn test_01() { diff --git a/src/windows_native/descriptor/typedefs.rs b/src/windows_native/descriptor/typedefs.rs index 6b6bdc5..d7246e5 100644 --- a/src/windows_native/descriptor/typedefs.rs +++ b/src/windows_native/descriptor/typedefs.rs @@ -1,5 +1,5 @@ use std::mem::size_of; -use crate::windows_native::descriptor::types::BitRange; +use super::types::BitRange; // Reverse engineered typedefs for the internal structure of the preparsed data taken from // https://github.com/libusb/hidapi/blob/master/windows/hidapi_descriptor_reconstruct.h diff --git a/src/windows_native/dev_node.rs b/src/windows_native/dev_node.rs index 16118a1..707c90a 100644 --- a/src/windows_native/dev_node.rs +++ b/src/windows_native/dev_node.rs @@ -1,9 +1,9 @@ use std::ptr::null_mut; use windows_sys::Win32::Devices::DeviceAndDriverInstallation::{CM_Get_DevNode_PropertyW, CM_Get_Parent, CM_LOCATE_DEVNODE_NORMAL, CM_Locate_DevNodeW, CR_BUFFER_SMALL, CR_SUCCESS}; use crate::ensure; -use crate::windows_native::error::{check_config, WinError, WinResult}; -use crate::windows_native::string::U16Str; -use crate::windows_native::types::{DeviceProperty, PropertyKey}; +use super::error::{check_config, WinError, WinResult}; +use super::string::U16Str; +use super::types::{DeviceProperty, PropertyKey}; #[repr(transparent)] #[derive(Debug, Copy, Clone, Eq, PartialEq)] diff --git a/src/windows_native/device_info.rs b/src/windows_native/device_info.rs index cbef896..c1092e4 100644 --- a/src/windows_native/device_info.rs +++ b/src/windows_native/device_info.rs @@ -5,12 +5,12 @@ use windows_sys::Win32::Devices::Properties::{DEVPKEY_Device_CompatibleIds, DEVP use windows_sys::Win32::Foundation::{BOOLEAN, HANDLE}; use windows_sys::Win32::Storage::EnhancedStorage::{PKEY_DeviceInterface_Bluetooth_DeviceAddress, PKEY_DeviceInterface_Bluetooth_Manufacturer, PKEY_DeviceInterface_Bluetooth_ModelNumber}; use crate::{BusType, DeviceInfo, WcharString}; -use crate::windows_native::dev_node::DevNode; -use crate::windows_native::error::WinResult; -use crate::windows_native::hid::{get_hid_attributes, PreparsedData}; -use crate::windows_native::interfaces::Interface; -use crate::windows_native::string::{U16Str, U16String, U16StringList}; -use crate::windows_native::types::{Handle, InternalBusType}; +use super::dev_node::DevNode; +use super::error::WinResult; +use super::hid::{get_hid_attributes, PreparsedData}; +use super::interfaces::Interface; +use super::string::{U16Str, U16String, U16StringList}; +use super::types::{Handle, InternalBusType}; fn read_string(func: unsafe extern "system" fn (HANDLE, *mut c_void, u32) -> BOOLEAN, handle: &Handle) -> WcharString { //Return empty string on failure to match the c implementation diff --git a/src/windows_native/hid.rs b/src/windows_native/hid.rs index 99fb6b7..9639a52 100644 --- a/src/windows_native/hid.rs +++ b/src/windows_native/hid.rs @@ -3,8 +3,8 @@ use std::mem::{size_of, zeroed}; use windows_sys::core::GUID; use windows_sys::Win32::Devices::HumanInterfaceDevice::{HIDD_ATTRIBUTES, HidD_FreePreparsedData, HidD_GetAttributes, HidD_GetHidGuid, HidD_GetPreparsedData, HIDP_CAPS, HidP_GetCaps, HIDP_STATUS_SUCCESS}; use crate::ensure; -use crate::windows_native::error::{check_boolean, WinError, WinResult}; -use crate::windows_native::types::Handle; +use super::error::{check_boolean, WinError, WinResult}; +use super::types::Handle; pub fn get_interface_guid() -> GUID { unsafe { diff --git a/src/windows_native/interfaces.rs b/src/windows_native/interfaces.rs index da32722..569937d 100644 --- a/src/windows_native/interfaces.rs +++ b/src/windows_native/interfaces.rs @@ -2,10 +2,10 @@ use std::ptr::{null, null_mut}; use windows_sys::core::GUID; use windows_sys::Win32::Devices::DeviceAndDriverInstallation::{CM_GET_DEVICE_INTERFACE_LIST_PRESENT, CM_Get_Device_Interface_List_SizeW, CM_Get_Device_Interface_ListW, CM_Get_Device_Interface_PropertyW, CR_BUFFER_SMALL, CR_SUCCESS}; use crate::ensure; -use crate::windows_native::error::{check_config, WinError, WinResult}; -use crate::windows_native::hid::get_interface_guid; -use crate::windows_native::string::{U16Str, U16StringList}; -use crate::windows_native::types::{DeviceProperty, PropertyKey}; +use super::error::{check_config, WinError, WinResult}; +use super::hid::get_interface_guid; +use super::string::{U16Str, U16StringList}; +use super::types::{DeviceProperty, PropertyKey}; pub struct Interface; diff --git a/src/windows_native/mod.rs b/src/windows_native/mod.rs index 334a0bf..71cfddb 100644 --- a/src/windows_native/mod.rs +++ b/src/windows_native/mod.rs @@ -24,14 +24,14 @@ use windows_sys::Win32::Foundation::{GENERIC_READ, GENERIC_WRITE, INVALID_HANDLE use windows_sys::Win32::Storage::FileSystem::{CreateFileW, FILE_FLAG_OVERLAPPED, FILE_SHARE_READ, FILE_SHARE_WRITE, OPEN_EXISTING, ReadFile, WriteFile}; use windows_sys::Win32::System::IO::{CancelIo, DeviceIoControl}; use windows_sys::Win32::System::Threading::ResetEvent; -use crate::{DeviceInfo, HidDeviceBackendBase, HidDeviceBackendWindows, HidError, HidResult}; -use crate::windows_native::dev_node::DevNode; -use crate::windows_native::device_info::get_device_info; -use crate::windows_native::error::{check_boolean, Win32Error, WinError, WinResult}; -use crate::windows_native::hid::{get_hid_attributes, PreparsedData}; -use crate::windows_native::interfaces::Interface; -use crate::windows_native::string::{U16Str, U16String}; -use crate::windows_native::types::{Handle, Overlapped}; +use super::{DeviceInfo, HidDeviceBackendBase, HidDeviceBackendWindows, HidError, HidResult}; +use dev_node::DevNode; +use device_info::get_device_info; +use error::{check_boolean, Win32Error, WinError, WinResult}; +use hid::{get_hid_attributes, PreparsedData}; +use interfaces::Interface; +use string::{U16Str, U16String}; +use types::{Handle, Overlapped}; const STRING_BUF_LEN: usize = 128; diff --git a/src/windows_native/string.rs b/src/windows_native/string.rs index 03e1b24..3fb9947 100644 --- a/src/windows_native/string.rs +++ b/src/windows_native/string.rs @@ -7,7 +7,7 @@ use std::str::Utf8Error; use windows_sys::core::PCWSTR; use windows_sys::Win32::Devices::Properties::{DEVPROP_TYPE_STRING, DEVPROP_TYPE_STRING_LIST, DEVPROPTYPE}; use crate::WcharString; -use crate::windows_native::types::DeviceProperty; +use super::types::DeviceProperty; #[repr(transparent)] pub struct U16Str([u16]); diff --git a/src/windows_native/types.rs b/src/windows_native/types.rs index 7c850b4..3051958 100644 --- a/src/windows_native/types.rs +++ b/src/windows_native/types.rs @@ -7,7 +7,7 @@ use windows_sys::Win32::System::IO::{GetOverlappedResultEx, OVERLAPPED}; use windows_sys::Win32::System::Threading::{CreateEventW, INFINITE}; use windows_sys::Win32::UI::Shell::PropertiesSystem::PROPERTYKEY; use crate::{BusType, ensure}; -use crate::windows_native::error::{WinError, WinResult}; +use super::error::{WinError, WinResult}; #[allow(clippy::missing_safety_doc)] pub unsafe trait DeviceProperty { From 16e5ea0c9cca31a3b96d4553ec91b3e1d846f6f2 Mon Sep 17 00:00:00 2001 From: sidit77 Date: Wed, 10 Jan 2024 23:35:50 +0100 Subject: [PATCH 2/4] removed unnecessary extern crate statements --- src/lib.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 0face6b..7c816a0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -58,10 +58,6 @@ //! [`HidDevice`] handles can access the same physical device. For backward compatibility this is //! an opt-in that can be enabled with the `macos-shared-device` feature flag. -extern crate libc; -#[cfg(all(feature = "linux-native", target_os = "linux"))] -extern crate nix; - #[cfg(target_os = "windows")] use windows_sys::core::GUID; From d534a3939d88f90d6c3b3960064ae744f5e8ffa3 Mon Sep 17 00:00:00 2001 From: sidit77 Date: Thu, 11 Jan 2024 00:22:40 +0100 Subject: [PATCH 3/4] reduced the number of #[cfg] attributes by using cfg-if --- Cargo.toml | 1 + src/lib.rs | 112 ++++++++++++--------------- src/windows.rs | 2 +- src/windows_native/descriptor/mod.rs | 1 - src/windows_native/dev_node.rs | 1 - src/windows_native/hid.rs | 1 - src/windows_native/interfaces.rs | 1 - src/windows_native/mod.rs | 20 +++-- src/windows_native/types.rs | 2 +- 9 files changed, 62 insertions(+), 79 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 31dbd73..127d049 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,6 +42,7 @@ windows-native = [ [dependencies] libc = "0.2" +cfg-if = "1" [target.'cfg(target_os = "linux")'.dependencies] udev = { version = "0.7", optional = true } diff --git a/src/lib.rs b/src/lib.rs index 7c816a0..57cd0a3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -58,44 +58,68 @@ //! [`HidDevice`] handles can access the same physical device. For backward compatibility this is //! an opt-in that can be enabled with the `macos-shared-device` feature flag. -#[cfg(target_os = "windows")] -use windows_sys::core::GUID; - mod error; mod ffi; -#[cfg(hidapi)] -mod hidapi; - -#[cfg(all(feature = "linux-native", target_os = "linux"))] -#[cfg_attr(docsrs, doc(cfg(all(feature = "linux-native", target_os = "linux"))))] -mod linux_native; -#[cfg(target_os = "macos")] -#[cfg_attr(docsrs, doc(cfg(target_os = "macos")))] -mod macos; -#[cfg(target_os = "windows")] -#[cfg_attr(docsrs, doc(cfg(target_os = "windows")))] -mod windows; - -#[cfg(feature = "windows-native")] -#[cfg_attr(docsrs, doc(cfg(all(feature = "windows-native", target_os = "windows"))))] -mod windows_native; - use libc::wchar_t; use std::ffi::CStr; use std::ffi::CString; use std::fmt; use std::fmt::Debug; use std::sync::Mutex; +use cfg_if::cfg_if; pub use error::HidError; -#[cfg(hidapi)] -use crate::hidapi::HidApiBackend; -#[cfg(all(feature = "linux-native", target_os = "linux"))] -use linux_native::HidApiBackend; -#[cfg(all(feature = "windows-native", target_os = "windows"))] -use windows_native::HidApiBackend; +cfg_if! { + if #[cfg(all(feature = "linux-native", target_os = "linux"))] { + //#[cfg_attr(docsrs, doc(cfg(all(feature = "linux-native", target_os = "linux"))))] + mod linux_native; + use linux_native::HidApiBackend; + } else if #[cfg(all(feature = "windows-native", target_os = "windows"))] { + //#[cfg_attr(docsrs, doc(cfg(all(feature = "windows-native", target_os = "windows"))))] + mod windows_native; + use windows_native::HidApiBackend; + } else if #[cfg(hidapi)] { + mod hidapi; + use hidapi::HidApiBackend; + } else { + compile_error!("No backend selected"); + } +} + +// Automatically implement the top trait +cfg_if! { + if #[cfg(target_os = "windows")] { + #[cfg_attr(docsrs, doc(cfg(target_os = "windows")))] + mod windows; + use windows::GUID; + /// A trait with the extra methods that are available on Windows + trait HidDeviceBackendWindows { + /// Get the container ID for a HID device + fn get_container_id(&self) -> HidResult; + } + trait HidDeviceBackend: HidDeviceBackendBase + HidDeviceBackendWindows + Send {} + impl HidDeviceBackend for T where T: HidDeviceBackendBase + HidDeviceBackendWindows + Send {} + } else if #[cfg(target_os = "macos")] { + #[cfg_attr(docsrs, doc(cfg(target_os = "macos")))] + mod macos; + /// A trait with the extra methods that are available on macOS + trait HidDeviceBackendMacos { + /// Get the location ID for a [`HidDevice`] device. + fn get_location_id(&self) -> HidResult; + + /// Check if the device was opened in exclusive mode. + fn is_open_exclusive(&self) -> HidResult; + } + trait HidDeviceBackend: HidDeviceBackendBase + HidDeviceBackendMacos + Send {} + impl HidDeviceBackend for T where T: HidDeviceBackendBase + HidDeviceBackendMacos + Send {} + } else { + trait HidDeviceBackend: HidDeviceBackendBase + Send {} + impl HidDeviceBackend for T where T: HidDeviceBackendBase + Send {} + } +} + pub type HidResult = Result; pub const MAX_REPORT_DESCRIPTOR_SIZE: usize = 4096; @@ -463,42 +487,6 @@ trait HidDeviceBackendBase { } } -/// A trait with the extra methods that are available on macOS -#[cfg(target_os = "macos")] -trait HidDeviceBackendMacos { - /// Get the location ID for a [`HidDevice`] device. - fn get_location_id(&self) -> HidResult; - - /// Check if the device was opened in exclusive mode. - fn is_open_exclusive(&self) -> HidResult; -} - -/// A trait with the extra methods that are available on macOS -#[cfg(target_os = "windows")] -trait HidDeviceBackendWindows { - /// Get the container ID for a HID device - fn get_container_id(&self) -> HidResult; -} - -#[cfg(not(any(target_os = "macos", target_os = "windows")))] -trait HidDeviceBackend: HidDeviceBackendBase + Send {} -#[cfg(target_os = "macos")] -trait HidDeviceBackend: HidDeviceBackendBase + HidDeviceBackendMacos + Send {} -#[cfg(target_os = "windows")] -trait HidDeviceBackend: HidDeviceBackendBase + HidDeviceBackendWindows + Send {} - -/// Automatically implement the top trait -#[cfg(not(any(target_os = "macos", target_os = "windows")))] -impl HidDeviceBackend for T where T: HidDeviceBackendBase + Send {} - -/// Automatically implement the top trait -#[cfg(target_os = "macos")] -impl HidDeviceBackend for T where T: HidDeviceBackendBase + HidDeviceBackendMacos + Send {} - -/// Automatically implement the top trait -#[cfg(target_os = "windows")] -impl HidDeviceBackend for T where T: HidDeviceBackendBase + HidDeviceBackendWindows + Send {} - pub struct HidDevice { inner: Box, } diff --git a/src/windows.rs b/src/windows.rs index 346878e..99250eb 100644 --- a/src/windows.rs +++ b/src/windows.rs @@ -1,4 +1,4 @@ -use windows_sys::core::GUID; +pub use windows_sys::core::GUID; use crate::{HidDevice, HidResult}; impl HidDevice { diff --git a/src/windows_native/descriptor/mod.rs b/src/windows_native/descriptor/mod.rs index 5f236d3..9b62e19 100644 --- a/src/windows_native/descriptor/mod.rs +++ b/src/windows_native/descriptor/mod.rs @@ -8,7 +8,6 @@ mod tests; use std::collections::HashMap; use std::ffi::c_void; use std::slice; -use crate::ensure; use encoder::encode_descriptor; use typedefs::{Caps, HidpPreparsedData, LinkCollectionNode}; use types::{BitRange, ItemNodeType, MainItemNode, MainItems, ReportType}; diff --git a/src/windows_native/dev_node.rs b/src/windows_native/dev_node.rs index 707c90a..b62468c 100644 --- a/src/windows_native/dev_node.rs +++ b/src/windows_native/dev_node.rs @@ -1,6 +1,5 @@ use std::ptr::null_mut; use windows_sys::Win32::Devices::DeviceAndDriverInstallation::{CM_Get_DevNode_PropertyW, CM_Get_Parent, CM_LOCATE_DEVNODE_NORMAL, CM_Locate_DevNodeW, CR_BUFFER_SMALL, CR_SUCCESS}; -use crate::ensure; use super::error::{check_config, WinError, WinResult}; use super::string::U16Str; use super::types::{DeviceProperty, PropertyKey}; diff --git a/src/windows_native/hid.rs b/src/windows_native/hid.rs index 9639a52..052f2a3 100644 --- a/src/windows_native/hid.rs +++ b/src/windows_native/hid.rs @@ -2,7 +2,6 @@ use std::ffi::c_void; use std::mem::{size_of, zeroed}; use windows_sys::core::GUID; use windows_sys::Win32::Devices::HumanInterfaceDevice::{HIDD_ATTRIBUTES, HidD_FreePreparsedData, HidD_GetAttributes, HidD_GetHidGuid, HidD_GetPreparsedData, HIDP_CAPS, HidP_GetCaps, HIDP_STATUS_SUCCESS}; -use crate::ensure; use super::error::{check_boolean, WinError, WinResult}; use super::types::Handle; diff --git a/src/windows_native/interfaces.rs b/src/windows_native/interfaces.rs index 569937d..564b124 100644 --- a/src/windows_native/interfaces.rs +++ b/src/windows_native/interfaces.rs @@ -1,7 +1,6 @@ use std::ptr::{null, null_mut}; use windows_sys::core::GUID; use windows_sys::Win32::Devices::DeviceAndDriverInstallation::{CM_GET_DEVICE_INTERFACE_LIST_PRESENT, CM_Get_Device_Interface_List_SizeW, CM_Get_Device_Interface_ListW, CM_Get_Device_Interface_PropertyW, CR_BUFFER_SMALL, CR_SUCCESS}; -use crate::ensure; use super::error::{check_config, WinError, WinResult}; use super::hid::get_interface_guid; use super::string::{U16Str, U16StringList}; diff --git a/src/windows_native/mod.rs b/src/windows_native/mod.rs index 71cfddb..8fd4906 100644 --- a/src/windows_native/mod.rs +++ b/src/windows_native/mod.rs @@ -1,4 +1,12 @@ -//! The implementation which uses the C library to perform operations +//! The implementation which directly uses the win32 api to perform operations + +macro_rules! ensure { + ($cond:expr, $result:expr) => { + if !($cond) { + return $result; + } + }; +} mod types; mod error; @@ -35,16 +43,6 @@ use types::{Handle, Overlapped}; const STRING_BUF_LEN: usize = 128; -#[macro_export] -macro_rules! ensure { - ($cond:expr, $result:expr) => { - if !($cond) { - return $result; - } - }; -} - - pub struct HidApiBackend; impl HidApiBackend { pub fn get_hid_device_info_vector(vid: u16, pid: u16) -> HidResult> { diff --git a/src/windows_native/types.rs b/src/windows_native/types.rs index 3051958..9e4a141 100644 --- a/src/windows_native/types.rs +++ b/src/windows_native/types.rs @@ -6,7 +6,7 @@ use windows_sys::Win32::Foundation::{CloseHandle, FALSE, HANDLE, INVALID_HANDLE_ use windows_sys::Win32::System::IO::{GetOverlappedResultEx, OVERLAPPED}; use windows_sys::Win32::System::Threading::{CreateEventW, INFINITE}; use windows_sys::Win32::UI::Shell::PropertiesSystem::PROPERTYKEY; -use crate::{BusType, ensure}; +use crate::BusType; use super::error::{WinError, WinResult}; #[allow(clippy::missing_safety_doc)] From e9e83b02a0d959bf6e21dce4d347baf2a4329b37 Mon Sep 17 00:00:00 2001 From: sidit77 Date: Tue, 23 Jan 2024 09:52:48 +0100 Subject: [PATCH 4/4] fixed the import bug --- src/windows_native/descriptor/encoder.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/windows_native/descriptor/encoder.rs b/src/windows_native/descriptor/encoder.rs index 9ab3da7..60d61f8 100644 --- a/src/windows_native/descriptor/encoder.rs +++ b/src/windows_native/descriptor/encoder.rs @@ -1,5 +1,7 @@ -use super::typedefs::{Caps, LinkCollectionNode}; -use super::types::{ItemNodeType, Items, MainItemNode, MainItems}; +use crate::windows_native::descriptor::typedefs::{Caps, LinkCollectionNode}; +use crate::windows_native::descriptor::types::{ItemNodeType, Items, MainItemNode, MainItems}; +use crate::windows_native::error::{WinError, WinResult}; +use crate::windows_native::utils::PeakIterExt; pub fn encode_descriptor( main_item_list: &[MainItemNode],