use super::*;
#[doc(hidden)]
pub trait MachineImpl: 'static + Send + Sync {
type Adapter;
type SenderAdapter;
type InstructionSet: Send + Sync;
fn park_sender(
channel_id: usize,
sender: crossbeam::channel::Sender<Self::InstructionSet>,
instruction: Self::InstructionSet,
) -> Result<(), Self::InstructionSet>;
}
pub trait Machine<T>: Send + Sync
where
T: 'static + Send + Sync,
{
fn receive(&self, cmd: T);
fn disconnected(&self) {}
fn connected(&self, _uuid: Uuid) {}
}
impl<T, P> Machine<P> for Mutex<T>
where
T: Machine<P>,
P: MachineImpl,
{
fn receive(&self, cmd: P) { self.lock().unwrap().receive(cmd); }
fn disconnected(&self) { self.lock().unwrap().disconnected(); }
fn connected(&self, uuid: Uuid) { self.lock().unwrap().connected(uuid); }
}