Documentation ¶
Overview ¶
Package memio implements Read, Write, Seek, Close and other io methods for a byte slice.
Index ¶
- Variables
- type Buffer
- func (s *Buffer) Close() error
- func (s *Buffer) Peek(n int) ([]byte, error)
- func (s *Buffer) Read(p []byte) (int, error)
- func (s *Buffer) ReadAt(p []byte, off int64) (int, error)
- func (s *Buffer) ReadByte() (byte, error)
- func (s *Buffer) ReadFrom(r io.Reader) (int64, error)
- func (s *Buffer) ReadRune() (rune, int, error)
- func (s *Buffer) Write(p []byte) (int, error)
- func (s *Buffer) WriteAt(p []byte, off int64) (int, error)
- func (s *Buffer) WriteByte(b byte) error
- func (s *Buffer) WriteString(str string) (int, error)
- func (s *Buffer) WriteTo(w io.Writer) (int64, error)
- type LimitedBuffer
- func (s *LimitedBuffer) Close() error
- func (s *LimitedBuffer) Peek(n int) ([]byte, error)
- func (s *LimitedBuffer) Read(p []byte) (int, error)
- func (s *LimitedBuffer) ReadAt(p []byte, off int64) (int, error)
- func (s *LimitedBuffer) ReadByte() (byte, error)
- func (s *LimitedBuffer) ReadFrom(r io.Reader) (int64, error)
- func (s *LimitedBuffer) ReadRune() (rune, int, error)
- func (s *LimitedBuffer) Write(p []byte) (int, error)
- func (s *LimitedBuffer) WriteAt(p []byte, off int64) (int, error)
- func (s *LimitedBuffer) WriteByte(b byte) error
- func (s *LimitedBuffer) WriteString(str string) (int, error)
- func (s *LimitedBuffer) WriteTo(w io.Writer) (int64, error)
- type ReadMem
- type ReadWriteMem
- func (b *ReadWriteMem) Peek(n int) ([]byte, error)
- func (b *ReadWriteMem) Read(p []byte) (int, error)
- func (b *ReadWriteMem) ReadAt(p []byte, off int64) (int, error)
- func (b *ReadWriteMem) ReadByte() (byte, error)
- func (b *ReadWriteMem) UnreadByte() error
- func (b *ReadWriteMem) WriteTo(f io.Writer) (int64, error)
- type String
- type WriteMem
- func (b *WriteMem) Close() error
- func (b *WriteMem) ReadFrom(f io.Reader) (int64, error)
- func (b *WriteMem) Seek(offset int64, whence int) (int64, error)
- func (b *WriteMem) Truncate(s int64) error
- func (b *WriteMem) Write(p []byte) (int, error)
- func (b *WriteMem) WriteAt(p []byte, off int64) (int, error)
- func (b *WriteMem) WriteByte(c byte) error
- func (b *WriteMem) WriteString(s string) (int, error)
Constants ¶
This section is empty.
Variables ¶
var ErrClosed = errors.New("operation not permitted when closed")
ErrClosed is an error returned when trying to perform an operation after using Close().
var (
ErrInvalidUnreadByte = errors.New("invalid UnreadByte, no bytes read")
)
Errors
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer []byte
Buffer grants a byte slice very straightforward IO methods.
func (*Buffer) ReadAt ¶ added in v1.1.0
ReadAt satisfies the io.ReaderAt interface.
Care should be taken when used in conjunction with any other Read* calls as they will alter the start point of the buffer
func (*Buffer) WriteString ¶
WriteString writes a string to the buffer without casting to a byte slice
type LimitedBuffer ¶
type LimitedBuffer []byte
LimitedBuffer grants a byte slice very straightforward IO methods, limiting writing to the capacity of the slice
func (*LimitedBuffer) Close ¶
func (s *LimitedBuffer) Close() error
Close satisfies the io.Closer interface
func (*LimitedBuffer) Peek ¶
func (s *LimitedBuffer) Peek(n int) ([]byte, error)
Peek reads the next n bytes without advancing the position
func (*LimitedBuffer) Read ¶
func (s *LimitedBuffer) Read(p []byte) (int, error)
Read satisfies the io.Reader interface
func (*LimitedBuffer) ReadAt ¶ added in v1.1.0
func (s *LimitedBuffer) ReadAt(p []byte, off int64) (int, error)
ReadAt satisfies the io.ReaderAt interface
Care should be taken when used in conjunction with any other Read* calls as they will alter the start point of the buffer
func (*LimitedBuffer) ReadByte ¶
func (s *LimitedBuffer) ReadByte() (byte, error)
ReadByte satisfies the io.ByteReader interface
func (*LimitedBuffer) ReadFrom ¶
func (s *LimitedBuffer) ReadFrom(r io.Reader) (int64, error)
ReadFrom satisfies the io.ReaderFrom interface
func (*LimitedBuffer) ReadRune ¶
func (s *LimitedBuffer) ReadRune() (rune, int, error)
ReadRune satisfies the io.RuneReader interface
func (*LimitedBuffer) Write ¶
func (s *LimitedBuffer) Write(p []byte) (int, error)
Write satisfies the io.Writer interface
func (*LimitedBuffer) WriteAt ¶ added in v1.1.0
func (s *LimitedBuffer) WriteAt(p []byte, off int64) (int, error)
WriteAt satisfies the io.WriterAt interface
func (*LimitedBuffer) WriteByte ¶
func (s *LimitedBuffer) WriteByte(b byte) error
WriteByte satisfies the io.ByteWriter interface
func (*LimitedBuffer) WriteString ¶
func (s *LimitedBuffer) WriteString(str string) (int, error)
WriteString writes a string to the buffer without casting to a byte slice
type ReadMem ¶
ReadMem holds a byte slice that can be used for many io interfaces
func Open ¶
Open uses a byte slice for reading. Implements io.Reader, io.Seeker, io.Closer, io.ReaderAt, io.ByteReader and io.WriterTo.
type ReadWriteMem ¶
type ReadWriteMem struct {
WriteMem
}
ReadWriteMem is a combination of both the ReadMem and WriteMem types, allowing both all reads and writes to the same underlying byte slice.
func OpenMem ¶
func OpenMem(data *[]byte) *ReadWriteMem
OpenMem uses a byte slice for reading and writing. Implements io.Reader, io.Writer, io.Seeker, io.ReaderAt, io.ByteReader, io.WriterTo, io.WriterAt, io.ByteWriter and io.ReaderFrom.
func (*ReadWriteMem) Peek ¶
func (b *ReadWriteMem) Peek(n int) ([]byte, error)
Peek reads the next n bytes without advancing the position
func (*ReadWriteMem) Read ¶
func (b *ReadWriteMem) Read(p []byte) (int, error)
Read is an implementation of the io.Reader interface
func (*ReadWriteMem) ReadAt ¶
func (b *ReadWriteMem) ReadAt(p []byte, off int64) (int, error)
ReadAt is an implementation of the io.ReaderAt interface
func (*ReadWriteMem) ReadByte ¶
func (b *ReadWriteMem) ReadByte() (byte, error)
ReadByte is an implementation of the io.ByteReader interface
func (*ReadWriteMem) UnreadByte ¶
func (b *ReadWriteMem) UnreadByte() error
UnreadByte implements the io.ByteScanner interface
type String ¶
type String string
String grants a string Read-Only methods.
type WriteMem ¶
type WriteMem struct {
// contains filtered or unexported fields
}
WriteMem holds a pointer to a byte slice and allows numerous io interfaces to be used with it.
func Create ¶
Create uses a byte slice for writing. Implements io.Writer, io.Seeker, io.Closer, io.WriterAt, io.ByteWriter and io.ReaderFrom.