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
want — min(want, available), never negative — and the window with that
amount debited.
Types
@type t() :: %Terminalwire.Window{available: integer()}
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
want — min(want, available), never negative — and the window with that
amount debited.