writer.go 656 B

1234567891011121314151617181920212223242526272829
  1. package pipe
  2. import (
  3. "github.com/xtls/xray-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. func (w *Writer) Len() int32 {
  18. return w.pipe.Len()
  19. }
  20. // Interrupt implements common.Interruptible.
  21. func (w *Writer) Interrupt() {
  22. w.pipe.Interrupt()
  23. }