Documentation ¶
Overview ¶
Package runes provides unbounded, file-backed rune buffers and io-package-style interfaces for reading and writing rune slices.
Index ¶
- Constants
- func Copy(dst Writer, src Reader) (int64, error)
- func ReadAll(r Reader) ([]rune, error)
- func UTF8Reader(r Reader) io.Reader
- type Buffer
- func (b *Buffer) Close() error
- func (b *Buffer) Delete(n, offs int64) error
- func (b *Buffer) Insert(p []rune, offs int64) error
- func (b *Buffer) Read(n int, offs int64) ([]rune, error)
- func (b *Buffer) Reader(offs int64) Reader
- func (b *Buffer) ReaderFrom(offs int64) ReaderFrom
- func (b *Buffer) Reset()
- func (b *Buffer) Rune(offs int64) (rune, error)
- func (b *Buffer) Size() int64
- func (b *Buffer) Writer(offs int64) Writer
- type Reader
- type ReaderFrom
- type ReaderWriterAt
- type Writer
Constants ¶
const MinRead = bytes.MinRead
MinRead is the minimum rune buffer size passed to a Read call.
Variables ¶
This section is empty.
Functions ¶
func Copy ¶
Copy copies from src into dst until either EOF is reached or an error occurs. It returns the number of runes written or the first error encountered, if any.
A successful Copy returns err == nil, not err == io.EOF.
If dst implements the ReaderFrom interface, the copy is implemented by calling dst.ReadFrom.
func ReadAll ¶
ReadAll reads runes from the reader until an error or io.EOF is encountered. It returns all of the runes read. On success, the error is nil, not io.EOF.
func UTF8Reader ¶
UTF8Reader returns a buffering io.Reader that reads UTF8 from r.
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
A Buffer is an unbounded rune buffer backed by a file.
func NewBuffer ¶
NewBuffer returns a new, empty buffer. No more than blockSize runes are cached in memory.
func NewBufferReaderWriterAt ¶
func NewBufferReaderWriterAt(blockSize int, f ReaderWriterAt) *Buffer
NewBufferReaderWriterAt is like NewBuffer but uses the given ReaderWriterAt as its backing store. If the ReaderWriterAt implements io.Closer, it is closed when the buffer is closed. If the ReaderWriterAt is an *os.File, the file is removed when the buffer is closed.
func (*Buffer) Delete ¶
Delete deletes runes from the buffer starting at the given offset. It is an error to delete out of the range of the buffer.
func (*Buffer) Insert ¶
Insert inserts runes into the buffer at the given offset. It is an error to insert at a point than is out of the range of the buffer.
func (*Buffer) Read ¶
Read reads runes from the buffer beginning at a given offset. It is an error to read out of the range of the buffer.
func (*Buffer) Reader ¶
Reader returns a Reader that reads from the Buffer beginning at the given offset. The returned Reader need not be closed. The Buffer must not be modified between Read calls on the returned Reader.
func (*Buffer) ReaderFrom ¶
func (b *Buffer) ReaderFrom(offs int64) ReaderFrom
ReaderFrom returns a ReaderFrom that inserts into the Buffer beginning at the given offset.
type Reader ¶
Reader wraps the basic Read method. It behaves like io.Reader but it accepts a slice of runes instead of a slice of bytes, and returns the number of runes read instead of the number of bytes read.
func ByteReader ¶
ByteReader returns a Reader that reads runes from a []byte.
func EmptyReader ¶
func EmptyReader() Reader
EmptyReader returns a Reader that is empty. All calls to read return 0, io.EOF.
func LimitReader ¶
LimitReader returns a Reader that reads no more than n runes from r.
func RunesReader ¶
func RunesReader(r io.RuneReader) Reader
RunesReader returns a Reader that reads from an io.RuneReader.
func SliceReader ¶
SliceReader returns a Reader that reads runes from a slice.
func StringReader ¶
StringReader returns a Reader that reads runes from a string.
type ReaderFrom ¶
ReaderFrom wraps the ReadFrom method. It reads runes from the reader until there are no more runes to read.
type ReaderWriterAt ¶
A ReaderWriterAt implements the io.ReaderAt and io.WriterAt interfaces.