# `Estructura.Aston`
[🔗](https://github.com/am-kantox/estructura/blob/v1.13.0/lib/estructura/aston.ex#L1)

The implementation of `Estructura` ready to work with tree AST-like structure

# `t`

```elixir
@type t() :: %Estructura.Aston{
  name: atom() | binary(),
  attributes: map(),
  content: nil | binary() | [binary() | t()]
}
```

# `__generator__`

See `Estructura.Aston.__generator__/2`

# `__generator__`

Returns the generator to be used in `StreamData`-powered property testing, based
  on the specification given to `use Estructura`, which contained

## shape
```elixir
%Estructura.Config{
  access: true,
  coercion: true,
  validation: true,
  calculated: [],
  collectable: :content,
  enumerable: true,
  generator: [
    name: {StreamData, :string, [:alphanumeric]},
    attributes: {StreamData, :map_of,
     [
       {StreamData, :atom, [:alphanumeric]},
       {StreamData, :one_of,
        [
          [
            {StreamData, :integer},
            {StreamData, :boolean},
            {StreamData, :string, [:alphanumeric]}
          ]
        ]}
     ]},
    content: {StreamData, :tree,
     [{StreamData, :fixed_list, [[]]}, &Estructura.Aston.child_gen/1]}
  ]
}
```

The argument given would be used as a template to generate new values.

# `access`

Returns the key to be used for accessing the nested element(s)

# `coerce`

```elixir
@spec coerce(any(), keyword(), nil | any()) :: {:ok, value} | {:error, reason}
when value: any(), reason: String.t()
```

Coerces the deeply nested map to an instance of nested `Estructura.Aston`

# `get`

```elixir
@spec get(
  %Estructura.Aston{attributes: term(), content: term(), name: term()},
  Estructura.Config.key(),
  any()
) :: any()
```

Gets the value for the given key from the structure

# `put`

```elixir
@spec put(
  %Estructura.Aston{attributes: term(), content: term(), name: term()},
  Estructura.Config.key(),
  any()
) ::
  {:ok, %Estructura.Aston{attributes: term(), content: term(), name: term()}}
  | {:error, any()}
```

Puts the value for the given key into the structure, passing coercion _and_ validation,
  returns `{:ok, updated_struct}` or `{:error, reason}` if there is no such key

# `put!`

```elixir
@spec put!(
  %Estructura.Aston{attributes: term(), content: term(), name: term()},
  Estructura.Config.key(),
  any()
) ::
  %Estructura.Aston{attributes: term(), content: term(), name: term()}
  | no_return()
```

Puts the value for the given key into the structure, passing coercion _and_ validation,
  returns the value or raises if there is no such key

# `recalculate_calculated`

Recalculates calculated fields for the instance of Estructura.Aston.

Normally one would not need to call this function explicitly because `Access`
  implementation would do that.

# `to_ast`

```elixir
@spec to_ast(t()) :: {element, map(), content}
when element: atom() | binary(), content: nil | binary() | list()
```

Converts `Estructura.Aston` to the XML AST understandable by `XmlBuilder`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
