-
Hello all, I'm fairly new to rust and dbus (working through various tutorials and walkthroughs as I go along), and I've written up this bit of code that won't compile due to ownership/lifetime issues, and I was hoping someone here might be able to point me in the right direction on how to overcome:
The end goal is to be able to return the connection to be used in other functions to interact with dbus in various ways. However, Rust won't compile this with:
Attempting to dereference also just gives me an "lol no" error message. I'm sure I'm missing something obvious here, and perhaps I'm not asking in the right location (maybe stackoverflow?), but I thought I'd start here. I would be greatly appreciative of any guidance. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
I think there isn't one right answer to this question; there are several designs. Probably the easiest one is to create a struct like this:
And then in every method of The other option would be to create a struct that contains both a |
Beta Was this translation helpful? Give feedback.
I think there isn't one right answer to this question; there are several designs. Probably the easiest one is to create a struct like this:
And then in every method of
MyConnection
, construct the proxy and then call whatever methods you need on that.The other option would be to create a struct that contains both a
Connection
and aProxy
and that struct then has to use a crate likerental
because theProxy
references theConnection
. I guess this is more complicated, but I don't know because I never usedrental
myself.