# `Kettlecorn.Struct`
[🔗](https://github.com/mjrusso/kettlecorn/blob/v0.1.0/host/lib/kettlecorn/guest_terms.ex#L20)

A guest struct represented as data: its module and fields.

`Kettlecorn.ETF` produces this wrapper when the module atom exists on the
host. Otherwise the value stays a map with
`__struct__: {:unknown_atom, name}`.

Decoding it as a struct of `module` would allow that module's protocol
implementations to run on the host with guest-supplied fields. Validate
the fields before constructing a host struct:

    case value do
      %Kettlecorn.Struct{module: MyApp.Order, fields: fields} -> MyApp.Order.new(fields)
      _other -> {:error, :unexpected_value}
    end

The [Validating guest data notebook](guest-data.html)
validates quotes and dates, including structs nested in other data.

# `t`

```elixir
@type t() :: %Kettlecorn.Struct{fields: map(), module: atom()}
```

---

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