use std::future::Future;
use crate::backend::{Backend, DynBackend};
use crate::traits::{AsyncHidFeatureHandle, AsyncHidRead, AsyncHidWrite};
use crate::HidResult;
#[repr(transparent)]
pub struct DeviceReader(pub(crate) <DynBackend as Backend>::Reader);
#[repr(transparent)]
pub struct DeviceWriter(pub(crate) <DynBackend as Backend>::Writer);
#[repr(transparent)]
pub struct DeviceFeatureHandle(pub(crate) <DynBackend as Backend>::FeatureHandle);
pub type DeviceReaderWriter = (DeviceReader, DeviceWriter);
impl AsyncHidRead for DeviceReader {
#[inline]
fn read_input_report<'a>(&'a mut self, buf: &'a mut [u8]) -> impl Future<Output = HidResult<usize>> + Send + 'a {
self.0.read_input_report(buf)
}
}
impl AsyncHidWrite for DeviceWriter {
#[inline]
fn write_output_report<'a>(&'a mut self, buf: &'a [u8]) -> impl Future<Output = HidResult<()>> + Send + 'a {
self.0.write_output_report(buf)
}
}
impl AsyncHidRead for DeviceReaderWriter {
#[inline]
fn read_input_report<'a>(&'a mut self, buf: &'a mut [u8]) -> impl Future<Output = HidResult<usize>> + Send + 'a {
self.0.read_input_report(buf)
}
}
impl AsyncHidWrite for DeviceReaderWriter {
#[inline]
fn write_output_report<'a>(&'a mut self, buf: &'a [u8]) -> impl Future<Output = HidResult<()>> + Send + 'a {
self.1.write_output_report(buf)
}
}
impl AsyncHidFeatureHandle for DeviceFeatureHandle {
#[inline]
fn read_feature_report<'a>(&'a mut self, buf: &'a mut [u8]) -> impl Future<Output = HidResult<usize>> + Send + 'a {
self.0.read_feature_report(buf)
}
#[inline]
fn write_feature_report<'a>(&'a mut self, buf: &'a [u8]) -> impl Future<Output = HidResult<()>> + Send + 'a {
self.0.write_feature_report(buf)
}
}