Xbase.FieldEncoder (Xbase v0.1.0)

View Source

Field encoder for DBF data types.

This module provides encoding functionality for different DBF field types, converting Elixir values to binary data based on field descriptors. This is the reverse operation of Xbase.FieldParser.

Summary

Functions

Encodes a value to binary field data based on the field descriptor.

Functions

encode(field_desc, value)

Encodes a value to binary field data based on the field descriptor.

Parameters

  • field_desc - The field descriptor containing type and length information
  • value - The Elixir value to encode

Returns

  • {:ok, binary_data} - Successfully encoded binary
  • {:error, reason} - Encoding error with reason

Examples

iex> field_desc = %FieldDescriptor{type: "C", length: 10}
iex> Xbase.FieldEncoder.encode(field_desc, "John Doe")
{:ok, "John Doe  "}