migrate pattern structures from previous projects.

This commit is contained in:
Vixalie
2025-03-05 09:29:17 +08:00
parent b126a3105f
commit 82e6d51f55
9 changed files with 610 additions and 0 deletions

View 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>;
}