Documentation ¶
Overview ¶
Package input defines data types and functions for managing input data.
Index ¶
- func FromReader(r io.Reader) io.ReaderAt
- func Slice(r io.ReaderAt, low, high int) []byte
- type Input
- func (i *Input) Advance(n int) bool
- func (i *Input) Furthest() int
- func (i *Input) Peek() (byte, bool)
- func (i *Input) PeekBefore() (byte, bool)
- func (i *Input) Pos() int
- func (i *Input) ReadAt(b []byte, pos int64) (n int, err error)
- func (i *Input) ResetFurthest()
- func (i *Input) SeekTo(pos int) bool
- func (i *Input) Slice(low, high int) []byte
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromReader ¶
FromReader converts an io.Reader to an io.ReaderAt.
Types ¶
type Input ¶
type Input struct {
// contains filtered or unexported fields
}
Input represents the input data and is an efficient wrapper of io.ReaderAt which provides a nicer API, avoids repeated interface function calls, and uses a cache for buffered reading. An Input also tracks the index of the furthest byte that has been read.
func (*Input) Advance ¶
Advance moves the offset forward by 'n' bytes. Returns true if the advance was successful (n chars were successfully skipped) and false otherwise. Note that even if Advance returns true the next call to Peek may return false if the advance went to the exact end of the data.
func (*Input) Peek ¶
Peek returns the next byte in the stream or 'false' if there are no more bytes. Successive calls to Peek will return the same value unless there is a call to SeekTo or Advance in between.
func (*Input) PeekBefore ¶
func (*Input) ResetFurthest ¶
func (i *Input) ResetFurthest()
ResetFurthest resets the furthest read tracker to zero.