aerospike-client-rust icon indicating copy to clipboard operation
aerospike-client-rust copied to clipboard

Implement serde::Serialize and serde::Deserialize for aerospike::Value and aerospike::Record

Open austinjones opened this issue 2 years ago • 1 comments

Hello, Aerospike is a great database! Master-master replication is very cool. But we are struggling to write Rust code that interfaces it.

We are getting stuck on serialization and deserialization code. The aerospike::Value and aerospike::Record structs do not implement serde::ser::Serialize and serde::de::Deserialize. Any conversions between Rust structs and Aerospike values need to be implemented manually, field by field. Deserializing is particularly tricky, because aerospike::Value may be any variant. Application code needs to match on the enum in order to extract each value, and manually handle deserialization errors (invalid variants).

This library should be able to serialize this rust struct into an aerospike::Record:

use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize)]
struct MyModel {
  amount: f64,
  description: String,
  inner: AnotherStruct
}

It should also be able to deserialize an aerospike::Record into the struct, with errors if fields have incompatible Value variants.

austinjones avatar Jun 20 '22 19:06 austinjones

Hey, the client has serde serializers at least. Its behind a feature flag.

jonas32 avatar Jun 20 '22 20:06 jonas32