Module slice

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

Use apache_avro::serde::slice_opt for 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")]
    slice_field: &'a [u8],
}

Functionsยง

deserialize
get_schema_in_ctxt
Returns Schema::Bytes
serialize