teamplayer3 / postcard-bindgen

A crate which generates bindings for the postcard binary format for other languages than Rust.
Apache License 2.0
3 stars 3 forks source link

Compiler error if a serialized struct contains Arc (which is accepted by base postcard serializer) #41

Closed Shelim closed 1 month ago

Shelim commented 1 month ago

MRE:

#[derive(Serialize, PostcardBindings)]
pub struct Definition {
    // other fields
}
#[derive(Serialize, PostcardBindings)]
pub struct RegisterNewDefinition{
    id: u64,
    definition: Arc<Definition>,
    // other fields
}

This structs will be serialized properly in Postcard, but the BindGen results is: ⚠ The trait bound 'Arc<Definition>: GenJsBinding' is not satisfied

I need raw Definition around and I would vote against cloning it for the purpose of just serializing it to be send across process via websocket to javascript frontend.

I have also the same problem with RwLock

teamplayer3 commented 1 month ago

Thanks for your issue. I will add these types.

teamplayer3 commented 1 month ago

Could you check if changes in #42 resolves your issue?

@Shelim have you read this:

https://github.com/serde-rs/serde/blob/31000e1874ff01362f91e7b53794e402fab4fc78/serde/src/de/impls.rs#L2088C3-L2097C8

Shelim commented 1 month ago

@teamplayer3 I only need to serialize and send data to front-end, having them cloned in incoming json on the front-end side is perfectly fine - but nevertheless thanks for pointing that out.

For the changes, I believe so - I will test thoroughly later on :)