# rec_struct
[![Build Status](]( [![ Version](](

Erlang record to Elixir structure converter. Allows for simple defining of Elixir structures that automatically map to Erlang records imported from a header file.

## Installation

The package is [available in Hex]( and can be installed
by adding `rec_struct` to your list of dependencies in `mix.exs`:

def deps do
    {:rec_struct, "~> 0.2.0"}

Documentation can be generated with [ExDoc]( 
The documentation can also be found at [](

## Usage

To use record structures first the header file, from which the Erlang records will be imported, must be defined. That is done using the `defheader` macro:

defheader MyModule, "include/path_to_header/header.hrl", do

This will import the header and use `Record.defrecord` to define the macros that can be used to build and manipulate records directly in the `MyModule.Records` module 
that will be generated.

With the header imported now each individual record can be imported and mapped to an Elixir structure by using:

defheader TestHeader, "test/test.hrl" do
  defrecstruct TestRec, :test_record
  defrecstruct OtherTestRec, :other_test_record

This will define two structures in `TestHeader.Structures.TestRec` and `TestHeader.Structures.OtherTestRec` modules. Additionally two functions will be defined in

* `to_struct/1` which transforms an Erlang record (tuple) to the appropriate Elixir structure
* `to_record/1` which transforms and Elixir structure into a record.

Please see the [documentation]( for more information and examples.

## Note

Currently the `defheader` and `defrectstruct` macros only work correctly if `RecStruct` module is imported!