Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
austinjones opened this issue Jun 20, 2022 · 1 comment

Comments

@austinjones
Copy link

austinjones commented Jun 20, 2022

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.

@jonas32
Copy link
Contributor

jonas32 commented Jun 20, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants