Skip to main content

Module array_opt

Module array_opt 

Source
Expand description

(De)serialize an optional Rust array (Option<[T; N]>) as an Avro Schema::Union([Schema::Null, Schema::Array]).

This module is intended to be used through the Serde with attribute.

Use apache_avro::serde::array for non-optional array values.

See usage with below example:

#[derive(AvroSchema, Serialize, Deserialize)]
struct StructWithArray {
    #[avro(with = apache_avro::serde::array_opt::get_schema_in_ctxt::<i32>)]
    #[serde(with = "apache_avro::serde::array_opt")]
    array: Option<[i32; 10]>,
}

Functionsยง

deserialize
get_record_fields_in_ctxt
Returns None
get_schema_in_ctxt
Returns Schema::Union(Schema::Null, Schema::Array(T::get_schema_in_ctxt()))
serialize