migrate pattern structures from previous projects.
This commit is contained in:
37
src-tauri/src/protocols/mod.rs
Normal file
37
src-tauri/src/protocols/mod.rs
Normal file
@@ -0,0 +1,37 @@
|
||||
use btleplug::platform::Peripheral;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Clone, Error)]
|
||||
pub enum CoyoteProtocolError {
|
||||
#[error("Failed to connect to peripheral")]
|
||||
FailedToConnect,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum CoyoteChannel {
|
||||
A,
|
||||
B,
|
||||
}
|
||||
|
||||
pub trait CoyoteProtocol {
|
||||
fn identify(peripheral: &Peripheral) -> bool;
|
||||
fn connected(&mut self, peripheral: &Peripheral) -> Result<(), CoyoteProtocolError>;
|
||||
fn disconnect(&mut self) -> Result<(), CoyoteProtocolError>;
|
||||
fn notify_battery_level<F>(&self, callback: F)
|
||||
where
|
||||
F: FnOnce(Option<i16>);
|
||||
fn notify_strength_change<F>(&self, callback: F)
|
||||
where
|
||||
F: FnOnce((Option<i16>, Option<i16>));
|
||||
fn set_output_strength(
|
||||
&self,
|
||||
channel: CoyoteChannel,
|
||||
strength: i16,
|
||||
) -> Result<(), CoyoteProtocolError>;
|
||||
fn output(
|
||||
&self,
|
||||
channel: CoyoteChannel,
|
||||
data: Vec<u8>,
|
||||
maintain: bool,
|
||||
) -> Result<(), CoyoteProtocolError>;
|
||||
}
|
||||
Reference in New Issue
Block a user