Module avro_enum

Avro enum type implementation.

Authors: Ilya Staheev (ilya.staheev@klarna.com).

Description

Avro enum type implementation.

All symbols in an enum must be unique; duplicates are prohibited.

Internal data for an enum is the symbol string itself.

Data Types

array_type()

array_type() = #avro_array_type{type = avro:type_or_name(), custom = [avro:custom_prop()]}

avro_type()

avro_type() = primitive_type() | array_type() | enum_type() | fixed_type() | map_type() | record_type() | union_type()

avro_value()

avro_value() = avro:canonicalized_value() | #avro_value{type = avro:type_or_name(), data = avro:avro_value()} | [#avro_value{type = avro:type_or_name(), data = avro:avro_value()}] | [{avro:name(), #avro_value{type = avro:type_or_name(), data = avro:avro_value()}}] | avro_map:data() | {json, binary()} | {binary, binary()}

enum_type()

enum_type() = #avro_enum_type{name = avro:name(), namespace = avro:namespace(), aliases = [avro:name()], doc = avro:typedoc(), symbols = [avro:enum_symbol()], fullname = avro:fullname(), custom = [avro:custom_prop()]}

fixed_type()

fixed_type() = #avro_fixed_type{name = avro:name(), namespace = avro:namespace(), aliases = [avro:name()], size = pos_integer(), fullname = avro:fullname(), custom = [avro:custom_prop()]}

index()

index() = avro:enum_index()

map_type()

map_type() = #avro_map_type{type = avro:type_or_name(), custom = [avro:custom_prop()]}

name_raw()

name_raw() = atom() | string() | binary()

namespace()

namespace() = binary()

primitive_type()

primitive_type() = #avro_primitive_type{name = avro:name(), custom = [avro:custom_prop()]}

record_type()

record_type() = #avro_record_type{name = avro:name(), namespace = avro:namespace(), doc = avro:typedoc(), aliases = [avro:name()], fields = [avro:record_field()], fullname = avro:fullname(), custom = [avro:custom_prop()]}

symbol()

symbol() = avro:enum_symbol()

symbol_raw()

symbol_raw() = avro:enum_symbol_raw()

union_type()

union_type() = #avro_union_type{id2type = avro_union:id2type(), name2id = avro_union:name2id()}

Function Index

cast/2Enums can be casted from other enums or strings.
get_index/1Get symbol index from boxed value.
get_index/2Get symbol index from type definition.
get_symbol_from_index/2Find symbol from index.
get_value/1Get the enum symbol.
new/2Create a enum wrapped (boxed) value.
resolve_fullname/2Resolve fullname by newly discovered enclosing namespace.
type/2Declare a enum type with default properties.
type/3Declare a enum type.

Function Details

cast/2

cast(Type::avro_type(), Value::symbol_raw()) -> {ok, avro_value()} | {error, term()}

Enums can be casted from other enums or strings.

get_index/1

get_index(Value::avro_value()) -> index()

Get symbol index from boxed value.

get_index/2

get_index(Type::enum_type(), Symbol::symbol_raw()) -> index()

Get symbol index from type definition.

get_symbol_from_index/2

get_symbol_from_index(T::enum_type(), Index::index()) -> symbol()

Find symbol from index.

get_value/1

get_value(Value::avro_value()) -> symbol()

Get the enum symbol.

new/2

new(Type::enum_type(), Value::avro_value() | symbol_raw()) -> avro_value() | no_return()

Create a enum wrapped (boxed) value.

resolve_fullname/2

resolve_fullname(Avro_enum_type::enum_type(), Ns::namespace()) -> enum_type()

Resolve fullname by newly discovered enclosing namespace.

type/2

type(Name::name_raw(), Symbols::[symbol_raw()]) -> enum_type() | no_return()

Declare a enum type with default properties.

type/3

type(Name0::name_raw(), Symbols0::[symbol_raw()], Opts::avro:type_props()) -> enum_type() | no_return()

Declare a enum type.


Generated by EDoc