Use AsRefClosure when generating the bindings
This simplifies things significantly \o/
This commit is contained in:
40
src/main.rs
40
src/main.rs
@@ -11,48 +11,20 @@ use padfoot::{
|
||||
ConnectionManager, Protocol, CM_BUS_NAME, CM_CONN_BUS_NAME, CM_OBJECT_PATH, CONN_BUS_NAME,
|
||||
PROTO_BUS_NAME, PROTO_OBJECT_PATH,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
struct TData {
|
||||
cm: ConnectionManager,
|
||||
p: Protocol,
|
||||
}
|
||||
|
||||
impl dbus::tree::DataType for TData {
|
||||
type Interface = Arc<TData>;
|
||||
type Tree = ();
|
||||
type Property = ();
|
||||
type ObjectPath = ();
|
||||
|
||||
type Method = ();
|
||||
type Signal = ();
|
||||
}
|
||||
|
||||
fn run() -> Result<()> {
|
||||
let (msg_s, msg_r) = std::sync::mpsc::channel::<dbus::message::Message>();
|
||||
let cm = ConnectionManager::new(Some(msg_s));
|
||||
let (cm, msg_r) = ConnectionManager::new();
|
||||
let cm_rc = std::rc::Rc::new(cm);
|
||||
|
||||
let proto = Protocol {};
|
||||
let data = Arc::new(TData { cm: cm, p: proto });
|
||||
let proto_rc = std::rc::Rc::new(proto);
|
||||
|
||||
let f = Factory::new_fn::<TData>();
|
||||
let f = Factory::new_fn::<()>();
|
||||
let mut tree = f.tree(());
|
||||
|
||||
let cm_iface = telepathy::connection_manager_server(&f, Arc::clone(&data), |m| {
|
||||
let a: &Arc<TData> = &m.iface.get_data();
|
||||
let b: &TData = &a;
|
||||
|
||||
&b.cm
|
||||
});
|
||||
|
||||
let proto_iface = telepathy::protocol_server(&f, Arc::clone(&data), |m| {
|
||||
let a: &Arc<TData> = &m.iface.get_data();
|
||||
let b: &TData = &a;
|
||||
|
||||
&b.p
|
||||
});
|
||||
let cm_iface = telepathy::connection_manager_server(&f, (), move |_| cm_rc.clone() );
|
||||
let proto_iface = telepathy::protocol_server(&f, (), move |_| proto_rc.clone() );
|
||||
|
||||
tree = tree.add(
|
||||
f.object_path(CM_OBJECT_PATH, ())
|
||||
|
Reference in New Issue
Block a user