Implement Serde's Serialize, Deserialize for SvmVec
Closed this issue · 4 comments
The Rust API Guidelines recommend that "Types that play the role of a data structure should implement Serialize and Deserialize", see: C-SERDE. Therefore, SvmVec should implement the serde Serialize
and Deserialize
traits.
I have been able to implement Serialize for SvmVec
. However, I cannot determine how to implement Deserialize for SvmVec
because the Deserialize method signature only takes a Deserializer
parameter. However, it needs to take an additional Context
parameter to allocate the SvmVec
memory.
Has anyone got any ideas how to implement Deserialize for SvmVec
?
I believe you want https://docs.serde.rs/serde/de/trait.DeserializeSeed.html
Thank you Jonathan, DeserializeSeed
looks perfect!
Added ExtendSvmVec
DeserializeSeed implementation for SvmVec
and opencl2serde.rs
example file in version 0.6.2
of the library.