2023-01-02 18:49:32 +01:00
|
|
|
|
|
|
|
pub trait Commander {
|
|
|
|
type Cmd;
|
|
|
|
|
|
|
|
fn send_cmd(&mut self, cmd: &Self::Cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
use std::sync::{Arc, RwLock};
|
|
|
|
use crate::{
|
2023-02-13 18:39:45 +01:00
|
|
|
type_system::ReprTree
|
2023-01-02 18:49:32 +01:00
|
|
|
};
|
2023-02-18 04:15:47 +01:00
|
|
|
|
|
|
|
//use r3vi::view::singleton::*;
|
2023-01-02 18:49:32 +01:00
|
|
|
|
|
|
|
pub trait ObjCommander {
|
|
|
|
fn send_cmd_obj(&mut self, cmd_obj: Arc<RwLock<ReprTree>>);
|
|
|
|
}
|
|
|
|
|
|
|
|
//impl<Cmd: 'static, T: Commander<Cmd>> ObjCommander for T {
|
|
|
|
impl<C: Commander> ObjCommander for C
|
|
|
|
where C::Cmd: 'static
|
|
|
|
{
|
|
|
|
fn send_cmd_obj(&mut self, cmd_obj: Arc<RwLock<ReprTree>>) {
|
2023-02-18 04:15:47 +01:00
|
|
|
/*
|
2023-01-02 18:49:32 +01:00
|
|
|
self.send_cmd(
|
|
|
|
&cmd_obj.read().unwrap()
|
|
|
|
.get_port::<dyn SingletonView<Item = C::Cmd>>().unwrap()
|
|
|
|
.get_view().unwrap()
|
|
|
|
.get()
|
2023-02-18 04:15:47 +01:00
|
|
|
);
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<T: Clone + Send + Sync> Commander for r3vi::buffer::vec::VecBuffer<T> {
|
|
|
|
type Cmd = r3vi::buffer::vec::VecDiff<T>;
|
|
|
|
|
|
|
|
fn send_cmd(&mut self, cmd: &Self::Cmd) {
|
|
|
|
self.apply_diff(cmd.clone());
|
2023-01-02 18:49:32 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|