You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As you can see, PubKey is only a Vec<u8>, what is the most idiomatic way to pack this. I do not want to put the Vec<u8> in a struct to use serde_bytes.
Is there something i am missing?
It would be really neat to annotated all_known just with #[serde(with="serde_bytes")].
It seems a pretty common problem to be to have an array of byte arrays.
The text was updated successfully, but these errors were encountered:
serde_bytes only supports a few types and cannot support arbitrary data structures. You can use the serde_with::Bytes type, which is more powerful than what serde_bytes offers and can be used with more collections. The crate documentation shows how you can use it in nested situations.
If you want to use serde_bytes, you will either need to write the deserialization logic for Vec<PubKey> yourself, for example by deserializing into a Vec<ByteBuf> and turning that into a Vec<PubKey>, or aliasing PubKey to ByteBuf, which already has the serialization behavior you want.
Something like this should work:
Hi,
i have a message to send in the form of:
As you can see,
PubKey
is only aVec<u8>
, what is the most idiomatic way to pack this. I do not want to put theVec<u8>
in a struct to useserde_bytes
.Is there something i am missing?
It would be really neat to annotated
all_known
just with#[serde(with="serde_bytes")]
.It seems a pretty common problem to be to have an array of byte arrays.
The text was updated successfully, but these errors were encountered: