I'm trying to use avro_rs to deserialize data into a struct with a Uuid field.
use avro_rs::types::Value;
use serde::Deserialize;
use uuid::Uuid;
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Metadata {
pub event_uuid: Uuid,
}
fn main() {
let uuid = Value::Uuid(Uuid::parse_str("936DA01F9ABD4d9d80C702AF85C822A8").unwrap());
let avro_uuid = avro_rs::from_value::<Uuid>(&uuid);
eprintln!("avro_uuid = {:#?}", avro_uuid);
let metadata = Value::Record(vec![("eventUuid".to_owned(), uuid)]);
let avro_metadata = avro_rs::from_value::<Metadata>(&metadata);
}
Cargo.toml
[package]
name = "pp-avro"
version = "0.1.0"
edition = "2018"
[dependencies]
avro-rs = { version = ">= 0.6" }
serde = "1.0"
serde_json = "1.0"
uuid = { version = "0.8.1", features = ["serde", "v4"] }
This gives me the error:
avro_uuid = Err(
Error {
message: "not a string|bytes|fixed",
},
)
It is impossible to create a Metadata object.