Module slice_opt

Module 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 &[u8] are always serialized as Value::Bytes. However, both Value::Bytes and Value::Fixed can be deserialized as &[u8].

Use apache_avro::serde::slice for non-optional bytes/fixed borrowed values.

See usage with below example:


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

Functionsยง

deserialize
get_schema_in_ctxt
Returns Schema::Union(Schema::Null, Schema::Bytes)
serialize