# Module LittleGhost::CodeMode::Protocol

Documentation version: Edge

Canonical HTML: https://littleghostai.org/docs/LittleGhost/CodeMode/Protocol.html

Length-prefixed JSON framing shared by code-mode parent and child hosts.
Frames are bounded before allocation and parsing.

## Constants

### `Error`

Raised for malformed or oversized frames.

### `MAX_FRAME_BYTES`

Largest encoded JSON payload accepted by the protocol.

## Instance methods

<a id="method-i-dump"></a>
### `#dump`

```ruby
#dump(value)
```

Returns one encoded frame for `value`.

<a id="method-i-extract-21"></a>
### `#extract!`

```ruby
#extract!(buffer)
```

Removes and returns one complete frame from `buffer`, or returns `nil` while
more bytes are required.

<a id="method-i-read"></a>
### `#read`

```ruby
#read(io)
```

Reads one complete frame from `io`, or returns `nil` at clean EOF.

<a id="method-i-write"></a>
### `#write`

```ruby
#write(io, value)
```

Encodes `value` and writes one complete frame to `io`.
