Module apache_avro::serde_avro_slice_opt

source ·
Expand description

Efficient (de)serialization of optional Avro bytes/fixed borrowed values.

This module is intended to be used through the Serde with attribute. Note that bytes: &[u8] are always serialized as Value::Bytes. However, both Value::Bytes and Value::Fixed can be deserialized as bytes: &[u8]. Use serde_avro_slice for non optional bytes/fixed borrowed values.

See usage with below example:

use apache_avro::serde_avro_slice_opt;
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize)]
struct StructWithBytes<'a> {
    #[serde(with = "serde_avro_slice_opt")]
    slice_field: Option<&'a [u8]>,
}

Functions§