Skip to main content

Module head

Module head 

Source

Structs§

HeadConfig
Configuration for head

Enums§

HeadMode
Mode for head operation

Functions§

head_bytes
Output first N bytes from data
head_bytes_from_end
Output all but last N bytes from data
head_file
Process a single file/stdin for head
head_file_direct
Ultra-fast direct path: single file, positive line count, writes directly to stdout fd without BufWriter overhead. Uses raw write(2) on Linux; on other platforms uses a small stack-buffered stdout. Returns Ok(true) on success, Ok(false) on file error (already printed).
head_lines
Output first N lines from data
head_lines_from_end
Output all but last N lines from data. Uses reverse scanning (memrchr_iter) for single-pass O(n) instead of 2-pass.
head_stdin_lines_streaming
Process head for stdin streaming (line mode, positive count) Reads chunks and counts lines, stopping early once count reached.
parse_size
Parse a numeric argument with optional suffix (K, M, G, etc.) Supports: b(512), kB(1000), K(1024), MB(1e6), M(1048576), GB(1e9), G(1<<30), TB, T, PB, P, EB, E, ZB, Z, YB, Y
sendfile_bytes
Use sendfile for zero-copy byte output on Linux. Falls back to read+write if sendfile fails (e.g., stdout is a terminal).