serde icon indicating copy to clipboard operation
serde copied to clipboard

derive `Deserialize` only for specific session types

Open dpc opened this issue 1 year ago • 0 comments

I have a type Address<V : NetworkValidation> that impls Deserialize only for Address<Unchecked>.

I'd like to use it in some other structs but derive Deserialize only for Address<Unchecked> :

#[derive(Serialize, Deserialize)]
#[serde(bound_type(deserialize = "Unchecked"))]
struct Foo<V> {
  address: Address<V>;
}

This should generate impl Desierialize for Foo<Unchecked>, by basically hardcoding V. This way the struct can remain generic. Existing bound is kind of like it, but for bounds, while I have a single (possibly multiple) concrete types only. Trying to make a sub-bound over V: NetworkValidation will not work AFAICT.

dpc avatar Dec 12 '24 23:12 dpc