2018-04-16 08:57:13 -04:00
|
|
|
package pipe
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"v2ray.com/core/common/buf"
|
|
|
|
)
|
|
|
|
|
2018-04-18 09:40:43 -04:00
|
|
|
// Reader is a buf.Reader that reads content from a pipe.
|
2018-04-16 08:57:13 -04:00
|
|
|
type Reader struct {
|
|
|
|
pipe *pipe
|
|
|
|
}
|
|
|
|
|
2018-04-18 09:40:43 -04:00
|
|
|
// ReadMultiBuffer implements buf.Reader.
|
2018-04-16 08:57:13 -04:00
|
|
|
func (r *Reader) ReadMultiBuffer() (buf.MultiBuffer, error) {
|
|
|
|
return r.pipe.ReadMultiBuffer()
|
|
|
|
}
|
|
|
|
|
2018-04-18 09:40:43 -04:00
|
|
|
// ReadMultiBufferWithTimeout reads content from a pipe within the given duration, or returns buf.ErrTimeout otherwise.
|
2018-04-16 08:57:13 -04:00
|
|
|
func (r *Reader) ReadMultiBufferWithTimeout(d time.Duration) (buf.MultiBuffer, error) {
|
|
|
|
return r.pipe.ReadMultiBufferWithTimeout(d)
|
|
|
|
}
|
|
|
|
|
2018-04-18 09:40:43 -04:00
|
|
|
// CloseError sets the pipe to error state. Both reading and writing from/to the pipe will return io.ErrClosedPipe.
|
2018-04-16 08:57:13 -04:00
|
|
|
func (r *Reader) CloseError() {
|
|
|
|
r.pipe.CloseError()
|
|
|
|
}
|