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
There are broadly two approaches we've considered:
impl sqlx::Encode/Decode for all the important types. This doesn't work transitively - if my parent struct is composed of fields that are all Encode/Decode then I need to either insert the struct as a table (i.e. each field gets its own column) or I need to impl Encode/Decode for the parent struct. But this gives us complete control over how we represent the data.
Rely on bincode::serialize/deserialize for complex structs. This lets us reuse a macro impl_sqlx_for_bincode_ty!(Foo) that simply calls bincode::serialize/deserialize to Encode/Decode for any struct that implements Serialize/Deserialize.
It looks like bincode provides some fairly strong storage guarantees so long-term I am leaning towards approach 2, perhaps wrapped to include some version bytes at the front.
The text was updated successfully, but these errors were encountered:
There are broadly two approaches we've considered:
impl sqlx::Encode/Decode
for all the important types. This doesn't work transitively - if my parent struct is composed of fields that are allEncode/Decode
then I need to either insert the struct as a table (i.e. each field gets its own column) or I need toimpl Encode/Decode
for the parent struct. But this gives us complete control over how we represent the data.Rely on
bincode::serialize/deserialize
for complex structs. This lets us reuse a macroimpl_sqlx_for_bincode_ty!(Foo)
that simply callsbincode::serialize/deserialize
toEncode/Decode
for any struct that implementsSerialize/Deserialize
.It looks like bincode provides some fairly strong storage guarantees so long-term I am leaning towards approach 2, perhaps wrapped to include some version bytes at the front.
The text was updated successfully, but these errors were encountered: