Skip to main content

Module bigdecimal_opt

Module bigdecimal_opt 

Source
Expand description

(De)serialize Option<BigDecimal> as a Schema::Union(Schema::Null, Schema::BigDecimal) instead of a Schema::Union(Schema::Null, Schema::String).

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

Use apache_avro::serde::bigdecimal for non-optional big decimals values.

When used with different serialization formats, this will write bytes.

See usage with below example:

#[derive(AvroSchema, Serialize, Deserialize)]
struct StructWithBigDecimal {
    #[avro(with)]
    #[serde(with = "apache_avro::serde::bigdecimal_opt")]
    decimal: Option<BigDecimal>,
}

Functionsยง

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