Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ByteBuffer ¶
type ByteBuffer []byte
type IoLineReader ¶ added in v0.0.2
IoLineReader is what a line consumer needs from a reader: just the line. LineReader is the reference implementation, anything else may stand in.
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) PeekBytes ¶ added in v0.0.3
func (lr *LineReader) PeekBytes(nBytes uint64) ([]byte, error)
PeekBytes looks at the next nBytes without consuming them: the same buffer-first pull as ReadBytes, but the offset stays put — the next read serves these same bytes again. Fewer only at the end (nil error while something is there); nothing at all: nil and the stream's error.
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.
func (*LineReader) SkipBytes ¶ added in v0.0.3
func (lr *LineReader) SkipBytes(nBytes uint64) (uint64, error)
SkipBytes consumes the next nBytes without handing them back — the companion of PeekBytes: peek, decide, skip. It IS ReadBytes with the buffer discarded (literally: that is the implementation, so the semantics can never drift), returning how many bytes went instead.