Documentation
¶
Overview ¶
Package contextio provides context-aware I/O primitives for Go.
Index ¶
- Variables
- func CopyContext(ctx context.Context, dst DeadlineWriter, src DeadlineReader, ...) (written int64, err error)
- func Pipe() (*PipeReader, *PipeWriter)
- func SetNonblock(f *os.File) error
- func SpliceContext(ctx context.Context, rwa DeadlineReadWriter, rwb DeadlineReadWriter, ...) (written int64, err error)
- type DeadlineReadCloser
- type DeadlineReadWriteCloser
- type DeadlineReadWriter
- type DeadlineReader
- type DeadlineWriteCloser
- type DeadlineWriter
- type PipeReader
- type PipeWriter
Constants ¶
This section is empty.
Variables ¶
var ErrClosedPipe = stdio.ErrClosedPipe
Functions ¶
func CopyContext ¶
func CopyContext(ctx context.Context, dst DeadlineWriter, src DeadlineReader, readTimeout *time.Duration) (written int64, err error)
CopyContext is equivalent to `io.Copy` but with context cancellation support (for deadline reader/writers). The optional `readTimeout` parameter can be used to set a timeout for individual read operations, if not provided read operations will block indefinitely (until the context is cancelled).
func Pipe ¶
func Pipe() (*PipeReader, *PipeWriter)
Pipe is equivalent to `io.Pipe` but with deadline support.
func SetNonblock ¶
func SpliceContext ¶
func SpliceContext(ctx context.Context, rwa DeadlineReadWriter, rwb DeadlineReadWriter, readTimeout *time.Duration) (written int64, err error)
SpliceContext copies data between two ReadWriters until EOF is reached on one of them. The optional `readTimeout` parameter can be used to set a timeout for individual read operations, if not provided read operations will block indefinitely (until the context is cancelled).
Types ¶
type DeadlineReadCloser ¶
type DeadlineReadCloser interface {
stdio.Closer
DeadlineReader
}
type DeadlineReadWriteCloser ¶
type DeadlineReadWriteCloser interface {
stdio.Closer
DeadlineReadWriter
}
type DeadlineReadWriter ¶
type DeadlineReadWriter interface {
DeadlineReader
DeadlineWriter
}
Full duplex I/O.
type DeadlineReader ¶
Reader types.
func NopDeadlineReader ¶
func NopDeadlineReader(r stdio.Reader) DeadlineReader
type DeadlineWriteCloser ¶
type DeadlineWriteCloser interface {
stdio.Closer
DeadlineWriter
}
type DeadlineWriter ¶
Writer types.
func NopDeadlineWriter ¶
func NopDeadlineWriter(w stdio.Writer) DeadlineWriter
type PipeReader ¶
type PipeReader struct {
// contains filtered or unexported fields
}
A PipeReader is the read half of a pipe.
func (*PipeReader) Close ¶
func (r *PipeReader) Close() error
func (*PipeReader) SetReadDeadline ¶
func (r *PipeReader) SetReadDeadline(t time.Time) error
type PipeWriter ¶
type PipeWriter struct {
// contains filtered or unexported fields
}
A PipeWriter is the write half of a pipe.
func (*PipeWriter) Close ¶
func (w *PipeWriter) Close() error
func (*PipeWriter) SetWriteDeadline ¶
func (w *PipeWriter) SetWriteDeadline(t time.Time) error