Skip to documentation
SLOP

tiny.acp.reader

Reference tiny.acp reader

Defined in tiny.acp.

A reader splits a stream of bytes into lines at each newline, inside one buffer whose size the caller fixes in advance.

API (7)

Types and contracts

Public types and contracts.

Values and defaults

Public values and defaults.

No direct callersNo direct callstiny.acpreader
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Source: lib/acp/src/reader/root.zig

zig
//! A reader splits a stream of bytes into lines at each newline, inside one buffer whose size the//! caller fixes in advance. The package's client reads the agent's output through it, and any//! program that reads newline-separated messages from a pipe can use it alone.//!//! Memory for input from another program has to stay bounded, and its size has to be known before//! that program starts.//!//! A line can arrive in pieces, one read can hold more than one line, the last line can lack its//! newline, and a line can be longer than any buffer set aside for it.//!//! The buffer holds the longest allowed line plus its newline, and `Storage.init` allocates it in//! one allocation. After `activate`, nothing the reader does allocates: the caller reads input into//! free space the reader hands out, and the reader returns each line as a slice of its buffer.//! Before it hands out free space, the reader moves the unread bytes to the front of the buffer//! (*compaction*), and a line returned earlier stops being valid then. A line longer than the limit//! stops the reader for good (*terminal*), before any caller parses it, and every later poll fails//! with `error.ReaderMessageCapacityExceeded`. The reader keeps counters a caller can read for the//! lines rejected and the bytes waiting, and a caller reads the longest line seen (*high-water//! mark*). The reader states the buffer's size formula and what the buffer leaves out in a//! compile-time record (*capacity claim*), and that record names a test for each promise it makes.//! `default_limits` sets the line limit to 2 MiB for callers with no size of their own.const capacity = @import("capacity.zig");const storage = @import("storage.zig");/// A line limit of 2 MiB (2 * 1024 * 1024 bytes) for callers with no size of their own. The package/// exports it as `acp.default_reader_limits`, and the README's example passes it to the client.pub const default_limits: Limits = .{ .message_bytes = 2 * 1024 * 1024 };pub const Capacity = capacity.Capacity;pub const Exhaustion = storage.Exhaustion;pub const Limits = capacity.Limits;pub const Poll = storage.Poll;pub const Status = storage.Status;pub const Storage = storage.Storage;

Source: lib/acp/src/root.zig:64

zig
pub const reader = @import("reader/root.zig");

Audit

Definitions1
Public names1
Members0
Version26.7.0
Revisiondaab053ee433