github.com/xmplusdev/xmcore@v1.8.11-0.20240412132628-5518b55526af/transport/pipe/writer.go (about)

     1  package pipe
     2  
     3  import (
     4  	"github.com/xmplusdev/xmcore/common/buf"
     5  )
     6  
     7  // Writer is a buf.Writer that writes data into a pipe.
     8  type Writer struct {
     9  	pipe *pipe
    10  }
    11  
    12  // WriteMultiBuffer implements buf.Writer.
    13  func (w *Writer) WriteMultiBuffer(mb buf.MultiBuffer) error {
    14  	return w.pipe.WriteMultiBuffer(mb)
    15  }
    16  
    17  // Close implements io.Closer. After the pipe is closed, writing to the pipe will return io.ErrClosedPipe, while reading will return io.EOF.
    18  func (w *Writer) Close() error {
    19  	return w.pipe.Close()
    20  }
    21  
    22  // Interrupt implements common.Interruptible.
    23  func (w *Writer) Interrupt() {
    24  	w.pipe.Interrupt()
    25  }