writer.go 662 B

12345678910111213141516171819202122232425
  1. package pipe
  2. import (
  3. "v2ray.com/core/common/buf"
  4. )
  5. // Writer is a buf.Writer that writes data into a pipe.
  6. type Writer struct {
  7. pipe *pipe
  8. }
  9. // WriteMultiBuffer implements buf.Writer.
  10. func (w *Writer) WriteMultiBuffer(mb buf.MultiBuffer) error {
  11. return w.pipe.WriteMultiBuffer(mb)
  12. }
  13. // Close implements io.Closer. After the pipe is closed, writing to the pipe will return io.ErrClosedPipe, while reading will return io.EOF.
  14. func (w *Writer) Close() error {
  15. return w.pipe.Close()
  16. }
  17. // CloseError sets the pipe to error state. Both reading and writing from/to the pipe will return io.ErrClosedPipe.
  18. func (w *Writer) CloseError() {
  19. w.pipe.CloseError()
  20. }