import { type OpenStream } from '../../../rs/stream.ts';
import { type ByteSource } from '../../../io/types.ts';
import type { AsyncLineIterator } from '../../../io/async_line_iterator.ts';
import { FileStat, type PathSpec } from '../../../types.ts';
export declare function readStdinAsync(stdin: ByteSource | null): Promise<Uint8Array | null>;
export declare function resolveSource(stdin: ByteSource | null): AsyncIterable<Uint8Array>;
/**
 * Whether an operand reads stdin. `dash` says a literal `-` names stdin, as
 * it does for most GNU tools; util-linux `rev` and binutils `strings` open it
 * as a file, so only /dev/stdin is stdin to them.
 */
export declare function isStdin(path: PathSpec, dash?: boolean): boolean;
/**
 * Whether a failed read means the operand never opened: nothing arrived from
 * it, and it is neither stdin, which is always open, nor a directory, which
 * opens and then fails to read. GNU names such an operand as it does a
 * missing one, not as a read error. Mirrors Python's never_opened.
 */
export declare function neverOpened(reader: AsyncLineIterator, path: PathSpec, error: unknown): boolean;
/**
 * The name a command's output gives an operand. Only a literal `-` is stdin by
 * name: /dev/stdin reads the same bytes, but GNU grep, head and tail name it as
 * the path it is.
 */
export declare function operandLabel(path: PathSpec, stdinName: string): string;
/**
 * The `==> name <==` banner head and tail print above an operand: null names
 * the stdin no operand named, which -v heads with the name `-` gets, and
 * `after` says a block printed before this one, which a blank line then
 * separates it from. Mirrors Python's operand_header.
 */
export declare function operandHeader(path: PathSpec | null, after?: boolean): Uint8Array;
/**
 * Whether head or tail banners its operands: under -v or for more than one
 * operand (a failed one included), never under -q. Mirrors Python's
 * shows_headers.
 */
export declare function showsHeaders(verbose: boolean, quiet: boolean, count: number): boolean;
/**
 * Read each operand from its backend, or from stdin for a stdin one.
 *
 * Every stdin operand shares one cursor, so a later `-` never replays bytes
 * an earlier one read, and the cursor never closes the input a later one may
 * still read. `sole` says stdin has exactly one reader, which takes the input
 * itself, so a scan that stops early closes it. `dash` is as in `isStdin`.
 */
export declare function stdinStream(read: (path: PathSpec) => AsyncIterable<Uint8Array>, stdin: ByteSource | null, sole?: boolean, dash?: boolean): (path: PathSpec) => AsyncIterable<Uint8Array>;
/** Stat each operand on its backend, or as a stream for a stdin one. */
export declare function stdinStat(stat: (path: PathSpec) => Promise<FileStat>, dash?: boolean): (path: PathSpec) => Promise<FileStat>;
/** Drive an already validated stream through bounded calls. Mirrors Python's stream_output. */
export declare function streamOutput(stream: OpenStream, source: Uint8Array | AsyncIterable<Uint8Array>, signal?: AbortSignal): AsyncIterableIterator<Uint8Array>;
//# sourceMappingURL=stream.d.ts.map