Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ByteBuffer ¶
type ByteBuffer []byte
type LineReader ¶
type LineReader struct {
BlockSize uint64
Buffers []*ByteBuffer
Offset uint64
Reader io.Reader
MaxLineLength uint64
LastEolType EolType // what ended the last line ReadLine served
CachedError error // the stream's last error (io.EOF included) — served once, then cleared
}
func NewLineReader ¶
func NewLineReader(reader io.Reader, blockSize uint64, maxLineSize uint64) *LineReader
func (*LineReader) Read ¶
func (lr *LineReader) Read(p []byte) (int, error)
Read implements io.Reader: fills p from the buffered chain first, then from the stream. Short reads at the end, io.EOF when nothing is left — the canonical contract.
func (*LineReader) ReadBytes ¶
func (lr *LineReader) ReadBytes(nBytes uint64) ([]byte, error)
ReadBytes hands back the next nBytes as raw bytes — buffer first: whatever already sits in the chain is served before touching the stream, then blocks are pulled until the count is met or the stream ends. At the end it may return fewer bytes (with a nil error while something came); nothing left at all: nil and the stream's error.
func (*LineReader) ReadLine ¶
func (lr *LineReader) ReadLine() ([]byte, error)
ReadLine returns the next line without its terminator, consuming it. A line ends at whatever happens first: '\r', '\n' or EOF; the pair \r\n counts as one terminator — even when it rides a block boundary: with the '\r' as the last buffered byte, another block is read before deciding (unless EOF got there first: a lone CR then). What ended the line lands in LastEolType: EolLf, EolCr, EolCrLf, or EolEof for a final unterminated line. At the very end: nil, io.EOF (and EolNone). A line growing past MaxLineLength without an EOL is an error.