Documentation ¶
Overview ¶
Package limitio brings `io.Reader` and `io.Writer` with limit.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrThresholdExceeded = errors.New("stream size exceeds threshold")
ErrThresholdExceeded indicates stream size exceeds threshold
Functions ¶
func AtMostFirstNBytes ¶
AtMostFirstNBytes takes at more n bytes from s
Types ¶
type ReadCloser ¶
ReadCloser works like io.LimitedReader( but with a Close() method) but may be tuned to report oversize read as a distinguishable error other than io.EOF.
User NewReadCloser() to create ReadCloser.
func NewReadCloser ¶
func NewReadCloser(r io.ReadCloser, limit int, regardOverSizeEOF bool) *ReadCloser
NewReadCloser creates a ReadCloser that works like io.LimitedReader(but with a Close() method) and it may be tuned to report oversize read as a distinguishable error other than io.EOF.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader works like io.LimitedReader but may be tuned to report oversize read as a distinguishable error other than io.EOF.
Use NewReader() to create Reader.
type WriteCloser ¶
WriteCloser wraps w with writing length limit.
To create WriteCloser, use NewWriteCloser().
func NewWriteCloser ¶
func NewWriteCloser(w io.WriteCloser, n int, silentWhenOverSize bool) *WriteCloser
NewWriteCloser create a WriteCloser that writes at most n bytes.
regardOverSizeNormal controls whether Writer.Write() returns error when writing totally more bytes than n, or do no-op to inner w, pretending writing is processed normally.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer wraps w with writing length limit.
To create Writer, use NewWriter().
func NewWriter ¶
NewWriter create a writer that writes at most n bytes.
regardOverSizeNormal controls whether Writer.Write() returns error when writing totally more bytes than n, or do no-op to inner w, pretending writing is processed normally.