#[cfg(feature = "btleplug-manager")]
pub mod btleplug;
#[cfg(all(feature = "xinput-manager", target_os = "windows"))]
pub mod xinput;
#[cfg(feature = "btleplug-manager")]
use ::btleplug::Error as BtleplugError;
#[cfg(all(feature = "xinput-manager", target_os = "windows"))]
use rusty_xinput::XInputUsageError;
#[cfg(feature = "serial-manager")]
pub mod serialport;
#[cfg(feature = "lovense-dongle-manager")]
pub mod lovense_dongle;
use crate::{core::ButtplugResultFuture, device::ButtplugDeviceImplCreator};
use async_channel::Sender;
use std::sync::{atomic::AtomicBool, Arc};
use thiserror::Error;
pub enum DeviceCommunicationEvent {
DeviceFound(Box<dyn ButtplugDeviceImplCreator>),
DeviceManagerAdded(Arc<AtomicBool>),
ScanningFinished,
}
pub trait DeviceCommunicationManagerCreator: Send {
fn new(sender: Sender<DeviceCommunicationEvent>) -> Self;
}
pub trait DeviceCommunicationManager: Send + Sync {
fn name(&self) -> &'static str;
fn start_scanning(&self) -> ButtplugResultFuture;
fn stop_scanning(&self) -> ButtplugResultFuture;
fn scanning_status(&self) -> Arc<AtomicBool> {
Arc::new(AtomicBool::new(false))
}
}
#[derive(Error, Debug, Clone)]
pub enum ButtplugDeviceSpecificError {
#[cfg(all(feature = "xinput-manager", target_os = "windows"))]
#[error("XInput usage error: {0:?}")]
XInputError(XInputUsageError),
#[cfg(feature = "btleplug-manager")]
#[error("Btleplug error: {0:?}")]
BtleplugError(BtleplugError),
}