writer.go 606 B

12345678910111213141516171819202122232425
  1. package pipe
  2. import (
  3. "github.com/v2fly/v2ray-core/v5/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. // Interrupt implements common.Interruptible.
  18. func (w *Writer) Interrupt() {
  19. w.pipe.Interrupt()
  20. }