Documentation
¶
Overview ¶
Package io slightly redefines and extends the standard io package.
The Reader and Writer base interfaces are redefined to also be Closers by default, as stream users should always have the clear option of closing the stream. It should generally be less awkward to implement NoOp Close methods when not needed, rather than always having to check for Closers to ensure clean termination.
Unlike the standard specification, Readers should always strive to fill the given byte slice, and always return an error on shorter reads. It is the caller's responsibility to decide on appropriate fragmented streaming, which they can control through slice length; Readers should not make assumptions in their place. In order to accomodate for time sensitive operations, or guard against infinite blocking, Reader implementations should provide explicit timeout mechanisms. Conversely, Read calls should not return an error if the read is complete.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var EOF = io.EOF
Functions ¶
This section is empty.
Types ¶
type BytesReader ¶ added in v0.2.0
type BytesReader []byte
A BytesReader attaches a simple Reader interface to a byte slice.
func (*BytesReader) Close ¶ added in v0.2.0
func (x *BytesReader) Close() error
type MultiWriter ¶ added in v0.2.1
type MultiWriter []Writer
A MultiWriter bundles multiple Writers together.
func (MultiWriter) Close ¶ added in v0.2.1
func (x MultiWriter) Close() error
type ReadBuffer ¶ added in v0.2.0
type ReadBuffer struct {
// contains filtered or unexported fields
}
A ReadBuffer pulls data in buffered chunks, minimizing the number of read calls to the underlying source Reader.
func ReadBufferMake ¶ added in v0.2.8
func ReadBufferMake(src Reader, buf []byte) *ReadBuffer
ReadBufferMake returns a ReadBuffer from [src]. [buf] may be nil, in which case a default sized buffer will be allocated.
func (*ReadBuffer) Close ¶ added in v0.2.0
func (x *ReadBuffer) Close() error
func (*ReadBuffer) Reset ¶ added in v0.2.0
func (x *ReadBuffer) Reset(src Reader)
Reset discards any pending data and sets the ReadBuffer to start reading from [src].
type ReadWriter ¶
type ReadWriter = io.ReadWriteCloser
func ReadWriterOf ¶ added in v0.2.7
func ReadWriterOf(rw io.ReadWriter) ReadWriter
ReadWriterOf is the ReadWrite equivalent of ReaderOf.
type Reader ¶
type Reader = io.ReadCloser
type WriteBuffer ¶ added in v0.2.0
type WriteBuffer struct {
// contains filtered or unexported fields
}
A WriteBuffer accumulates Write calls before forwarding them, minimizing calls to the destination.
func WriteBufferMake ¶ added in v0.2.8
func WriteBufferMake(dst Writer, buf []byte) *WriteBuffer
WriteBufferMake returns a WriteBuffer to [dst]. If [buf] is nil, a default will be allocated.
func (*WriteBuffer) Bytes ¶ added in v0.2.0
func (x *WriteBuffer) Bytes() []byte
Bytes returns the currently buffered data.
func (*WriteBuffer) Close ¶ added in v0.2.0
func (x *WriteBuffer) Close() error
Close flushes any remaining data before closing the destination Writer.
func (*WriteBuffer) Flush ¶ added in v0.2.0
func (x *WriteBuffer) Flush() error
Flush writes out any pending data.