Custom Type serialization #1157
-
Hi, I am wondering if someone can point me into the right direction, I am writing a dbus service for a module we have previouly written. this code is stored in a seperate library, For simplicity, Im just going to put some pseudo code, we have:
We have a function in that returns a vector of these structs, we would like to have an ZBUS service interface that we could query this infomation, so we have created an interface:
On this I get the following error
Which I understand but what is the best way to do this, I dont want to alter the code in the other module and use the derive macro on the I have had a look at how zvarient does it internally, and use the
I have looked over the documents and just cant see how to do this, so im obviously missing something, and help or pointers in the right direction would be greatly appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
All you need is:
|
Beta Was this translation helpful? Give feedback.
Ah sorry, I missed that part. Yeah, the orphan rule won't allow you to implement external traits for external types. As usual, the solution is to either create a wrapper type in your code that implements the
Type
trait, or ask the implementation to be added to zvariant (but it has to be a type that's used a lot for that to be justified since we can't and won't provide implementations for every type on the planet).BTW, this is a Rust question, not really zbus specific.