Allow owned ObjectServer instances
Apologies, this is rather a beginner question. I'm failing at trying to set up an ObjectServer
- my requirement is that everything is contained within a context struct (this will be a library with a internal dbus backend). So effectively I need:
struct Context {
connection: zbus::Connection,
object_server: zbus::ObjectServer,
}
Since the ObjectServer::new()
takes a reference to the Connection
, Rust screams at me no matter what I try. The naive implementation was of course
impl Context {
fn new() -> Self {
let c = Connection::new_session();
let o = ObjectServer::new(&c);
Context {c, o}
}
}
Which won't work because c
gets moved. And all other 50 tries of lifetimes, RefCells
, etc. attempts all failed too so at this point I'm lost. The only example for ObjectServer
I could find has a static lifetime so it doesn't cover this use-case. I'd appreciate any help here in how to store this in a struct. Thanks.