View Source Avrogen.Avro.Schema.CodeGenerator protocol (avrogen v0.8.5)
Protocol defining how different types representing an Avro schema should contribute to the code generation process.
Summary
Types
All the types that implement this protocol.
Functions
Returns whether this type contains any PII including any PII in nested types.
Returns the function responsible decoding the value from an avro map.
Returns the function for dropping the the PII values stored in this type.
Returns the elixir type spec for this Avro schema type.
Returns the function responsible for encoding the value to an avro map
Extract the external dependencies fro this schema.
Normalizes the schema by extracting all embedded schemas into global
and returning the
schema with the embedded types replaced with references to their global names.
Returns the snippet of code responsible for generating a random instance of this type.
Types
@type global() :: %{required(String.t()) => Avrogen.Avro.Schema.t()}
@type parent_namespace() :: String.t() | nil
@type scoped_embedded_types() :: boolean()
@type t() :: term()
All the types that implement this protocol.
Functions
@spec contains_pii?(Avrogen.Avro.Schema.t(), global()) :: boolean()
Returns whether this type contains any PII including any PII in nested types.
@spec decode_function(Avrogen.Avro.Schema.t(), atom(), global()) :: Macro.t()
Returns the function responsible decoding the value from an avro map.
Note the returned function should have a return type as a result tuple.
@spec drop_pii(Avrogen.Avro.Schema.t(), atom(), global()) :: Macro.t()
Returns the function for dropping the the PII values stored in this type.
@spec elixir_type(Avrogen.Avro.Schema.t()) :: Macro.t()
Returns the elixir type spec for this Avro schema type.
@spec encode_function(Avrogen.Avro.Schema.t(), atom(), global()) :: Macro.t()
Returns the function responsible for encoding the value to an avro map
This should return a function with an infallible return type
@spec external_dependencies(Avrogen.Avro.Schema.t()) :: [String.t()]
Extract the external dependencies fro this schema.
normalize(value, global, parent_namespace, scope_embedded_types \\ false)
View Source@spec normalize( Avrogen.Avro.Schema.t(), global(), parent_namespace(), scoped_embedded_types() ) :: {Avrogen.Avro.Schema.t(), global()}
Normalizes the schema by extracting all embedded schemas into global
and returning the
schema with the embedded types replaced with references to their global names.
@spec random_instance(Avrogen.Avro.Schema.t(), Keyword.t(), global()) :: Macro.t()
Returns the snippet of code responsible for generating a random instance of this type.