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

Low-level Thrift binary protocol request/response over a framed socket.

This module encodes Thrift `CALL` messages and decodes `REPLY` messages
using the binary protocol. It is intentionally ignorant of business logic —
`NebulaGraphEx.Thrift.GraphService` builds on this to provide typed calls.

## Thrift binary message layout (inside the frame)

    << 0x80, 0x01,        :: 2 bytes  — version + message type (CALL = 1)
       0x00, 0x00,        :: 2 bytes  — unused (version high bits)
       name_len::32-big,  :: 4 bytes  — method name length
       name::binary,      :: N bytes  — method name
       seq_id::32-big,    :: 4 bytes  — sequence number
       ...struct fields   :: variable — Thrift struct encoding
       0x00 >>            :: 1 byte   — STOP field

Replies mirror this layout but with message type `REPLY` (2) or
`EXCEPTION` (3).

# `binary_val`

Encodes a length-prefixed `binary` / `string`.

# `bool`

Encodes a `bool`.

# `byte_val`

Encodes a `byte`.

# `call`

```elixir
@spec call(NebulaGraphEx.Transport.socket(), binary(), iodata(), integer(), timeout()) ::
  {:ok, binary()} | {:error, term()}
```

Encodes and sends a Thrift `CALL` message, then receives and decodes the
`REPLY`.

* `socket` — a socket returned by `NebulaGraphEx.Transport.connect/3`
* `method` — binary method name, e.g. `"execute"`
* `args_iodata` — already-encoded struct fields (from `encode_struct/1`)
* `seq_id` — sequence number (any integer; 1 is fine for sequential use)
* `recv_timeout` — milliseconds to wait for the reply frame

Returns `{:ok, reply_payload}` where `reply_payload` is the raw bytes of
the reply message body (after the message header), or `{:error, reason}`.

# `cast`

```elixir
@spec cast(NebulaGraphEx.Transport.socket(), binary(), iodata(), integer()) ::
  :ok | {:error, term()}
```

Sends a one-way Thrift `CALL` (no reply expected, e.g. `signout`).

# `decode_bool`

Decodes a bool.

# `decode_byte`

Decodes a byte.

# `decode_double`

Decodes a double.

# `decode_i16`

Decodes an i16.

# `decode_i32`

Decodes an i32.

# `decode_i64`

Decodes an i64.

# `decode_string`

Decodes a length-prefixed binary/string.

# `double`

Encodes a `double`.

# `encode_message`

Encodes a Thrift binary message header + body.

# `field`

Encodes a field header (type byte + field id).

# `i16`

Encodes an `i16`.

# `i32`

Encodes an `i32`.

# `i64`

Encodes an `i64`.

# `list`

Encodes a list field (etype, count, then elements).

# `map`

Encodes a map field (ktype, vtype, count, then pairs).

# `msg_call`

# `msg_exception`

# `msg_reply`

# `next_field`

Skips field headers and returns `{field_id, type, rest}`.

# `stop`

Encodes the STOP byte that terminates a struct.

# `type_binary`

# `type_bool`

# `type_byte`

# `type_double`

# `type_i16`

# `type_i32`

# `type_i64`

# `type_list`

# `type_map`

# `type_set`

# `type_stop`

# `type_struct`

---

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