Terminalwire.Window (Terminalwire v0.1.0)

Copy Markdown View Source

The flow-control credit rule as a pure ledger — no processes, no I/O. Mirrors Ruby's Terminalwire::V2::Window and the Go protocol.Window, and is validated by the shared flow conformance corpus. The blocking behaviour when credit runs out is an implementation concern layered on top (the Session); this is just the protocol arithmetic: how much output may be in flight and how window_adjust extends it.

Summary

Functions

Extend the window (a window_adjust arrived), clamped to the protocol ceiling (Terminalwire.Protocol.max_window/0) so a peer can't grow the window unbounded.

Returns {taken, window}: the bytes that may be sent now toward a request for wantmin(want, available), never negative — and the window with that amount debited.

Types

t()

@type t() :: %Terminalwire.Window{available: integer()}

Functions

available(window)

grant(w, bytes)

Extend the window (a window_adjust arrived), clamped to the protocol ceiling (Terminalwire.Protocol.max_window/0) so a peer can't grow the window unbounded.

new(size)

take(w, want)

Returns {taken, window}: the bytes that may be sent now toward a request for wantmin(want, available), never negative — and the window with that amount debited.