Module apache_avro::serde_avro_slice

source ·
Expand description

Efficient (de)serialization of 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_opt for optional bytes/fixed borrowed values.

See usage with below example:

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

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

Functions§