@@ -124,11 +124,15 @@ pub type HidResult<T> = Result<T, HidError>;
124124pub const MAX_REPORT_DESCRIPTOR_SIZE : usize = 4096 ;
125125
126126enum InitState {
127- Uninit { device_discovery : bool } ,
127+ Uninit {
128+ #[ cfg( all( libusb, not( target_os = "freebsd" ) ) ) ]
129+ device_discovery : bool ,
130+ } ,
128131 Init ,
129132}
130133
131134static INIT_STATE : Mutex < InitState > = Mutex :: new ( InitState :: Uninit {
135+ #[ cfg( all( libusb, not( target_os = "freebsd" ) ) ) ]
132136 device_discovery : true ,
133137} ) ;
134138
@@ -151,6 +155,8 @@ impl HidApi {
151155 /// # Panics
152156 ///
153157 /// Panics if an hidapi context has already been initialized.
158+ #[ cfg( all( libusb, not( target_os = "freebsd" ) ) ) ]
159+ #[ cfg_attr( docsrs, doc( cfg( not( target_os = "freebsd" ) ) ) ) ]
154160 pub fn disable_device_discovery ( ) {
155161 if let InitState :: Uninit { device_discovery } = & mut * INIT_STATE . lock ( ) . unwrap ( ) {
156162 * device_discovery = false ;
@@ -166,8 +172,11 @@ impl HidApi {
166172 pub fn new ( ) -> HidResult < Self > {
167173 let mut init_state = INIT_STATE . lock ( ) . expect ( "HidApi context initialization" ) ;
168174
169- #[ allow( unused_variables) ]
170- if let InitState :: Uninit { device_discovery } = * init_state {
175+ if let InitState :: Uninit {
176+ #[ cfg( all( libusb, not( target_os = "freebsd" ) ) ) ]
177+ device_discovery,
178+ } = * init_state
179+ {
171180 #[ cfg( all( libusb, not( target_os = "freebsd" ) ) ) ]
172181 if !device_discovery {
173182 // Do not scan for devices in libusb_init()
0 commit comments