# `Errow.CData`
[🔗](https://github.com/kuku/errow/blob/v0.1.0/lib/errow/cdata.ex#L1)

Utilities for exporting `Errow` arrays to the **Apache Arrow C Data Interface** specification.

This allows zero-copy consumption by external native libraries such as:
  * **DuckDB** (`duckdb_arrow_scan`)
  * **Polars / arrow-rs** (`arrow::ffi::ArrowArray`)
  * **PyArrow** (`pyarrow.Array._import_from_c`)
  * **Custom NIFs in C, Rust, or Zig**

# `export_buffers`

```elixir
@spec export_buffers(struct(), keyword()) :: map()
```

Exports the raw memory buffers ready to be passed to NIFs or Arrow C Data Interface.

Returns a map with:
  * `:length` - Number of elements.
  * `:null_count` - Number of null values.
  * `:buffers` - List of binaries padded to 8-byte boundaries as per Arrow spec:
      - For `Errow.String` / `Errow.Binary`: `[validity, offsets, data]`
      - For `Errow.Numeric`: `[validity, data]`

# `export_schema`

```elixir
@spec export_schema(struct(), keyword()) :: map()
```

Generates the Arrow C Schema metadata map for an array.

Returns a map containing:
  * `:format` - The Arrow C format string (e.g. `"u"`, `"z"`, `"i"`, `"l"`, `"g"`, `"d:38,0"`, `"w:32"`).
  * `:name` - Column name (defaults to empty string `""`).
  * `:flags` - Integer bitfield (`2` for nullable).
  * `:n_buffers` - Count of buffers expected (`2` for primitives, `3` for variable-length binaries/strings).

---

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