reader.go 713 B

123456789101112131415161718192021222324252627
  1. package pipe
  2. import (
  3. "time"
  4. "v2ray.com/core/common/buf"
  5. )
  6. // Reader is a buf.Reader that reads content from a pipe.
  7. type Reader struct {
  8. pipe *pipe
  9. }
  10. // ReadMultiBuffer implements buf.Reader.
  11. func (r *Reader) ReadMultiBuffer() (buf.MultiBuffer, error) {
  12. return r.pipe.ReadMultiBuffer()
  13. }
  14. // ReadMultiBufferTimeout reads content from a pipe within the given duration, or returns buf.ErrTimeout otherwise.
  15. func (r *Reader) ReadMultiBufferTimeout(d time.Duration) (buf.MultiBuffer, error) {
  16. return r.pipe.ReadMultiBufferTimeout(d)
  17. }
  18. // CloseError sets the pipe to error state. Both reading and writing from/to the pipe will return io.ErrClosedPipe.
  19. func (r *Reader) CloseError() {
  20. r.pipe.CloseError()
  21. }