# `NebulaGraphEx.Thrift.Types`
[🔗](https://github.com/VChain/nebula_graph_ex/blob/v0.1.10/lib/nebula_graph_ex/thrift/types.ex#L1)

Thrift binary encoding and decoding of NebulaGraph data types.

This module handles the `Value` union, `DataSet`, `Row`, `Vertex`, `Edge`,
`Path`, and all other types defined in `priv/thrift/common.thrift`.

## Value union field IDs

The `Value` union in the Thrift IDL maps to these field IDs:

| Field | ID | Elixir type         |
|-------|----|---------------------|
| nVal  | 1  | `NullType` (i32)    |
| bVal  | 2  | `bool`              |
| iVal  | 3  | `i64`               |
| fVal  | 4  | `double`            |
| sVal  | 5  | `binary`            |
| dVal  | 6  | `Date` struct       |
| tVal  | 7  | `Time` struct       |
| dtVal | 8  | `DateTime` struct   |
| vVal  | 9  | `Vertex` struct     |
| eVal  | 10 | `Edge` struct       |
| pVal  | 11 | `Path` struct       |
| lVal  | 12 | `NList` struct      |
| mVal  | 13 | `NMap` struct       |
| uVal  | 14 | `NSet` struct       |
| gVal  | 15 | `DataSet` struct    |
| ggVal | 16 | `Geography` union   |
| duVal | 17 | `Duration` struct   |

# `decode_dataset`

```elixir
@spec decode_dataset(binary()) :: {map(), binary()}
```

Decodes a Thrift `DataSet` struct from binary.

Returns `{dataset_map, rest}` where `dataset_map` has:
* `:column_names` — list of binary column names
* `:rows` — list of decoded row value lists

# `decode_row`

```elixir
@spec decode_row(binary()) :: {list(), binary()}
```

Decodes a single `Row` struct. Returns `{list_of_raw_values, rest}`.

Each element in the list is a raw tagged value map as produced by
`decode_value/1`. `NebulaGraphEx.Value.decode/1` converts these to native
Elixir types.

# `decode_value`

```elixir
@spec decode_value(binary()) :: {{atom(), term()}, binary()}
```

Decodes a `Value` union struct from binary.

Returns `{{tag, value}, rest}` where `tag` is one of:
`:null`, `:bool`, `:integer`, `:float`, `:string`,
`:date`, `:time`, `:datetime`, `:vertex`, `:edge`, `:path`,
`:list`, `:map`, `:set`, `:dataset`, `:geography`, `:duration`.

# `encode_value`

```elixir
@spec encode_value(term()) :: iodata()
```

Encodes an Elixir value as a Thrift `Value` union struct.

Supported types:
* `nil` → `nVal` (NullType.__NULL__)
* `boolean` → `bVal`
* `integer` → `iVal`
* `float` → `fVal`
* `binary` → `sVal`
* `Date` → `dVal`
* `DateTime` → `dtVal`
* `Time` → `tVal`

---

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