2018-04-16 08:57:13 -04:00
|
|
|
package pipe
|
|
|
|
|
|
|
|
import (
|
2021-02-16 15:31:50 -05:00
|
|
|
"github.com/v2fly/v2ray-core/v4/common/buf"
|
2018-04-16 08:57:13 -04:00
|
|
|
)
|
|
|
|
|
2018-04-18 09:40:43 -04:00
|
|
|
// Writer is a buf.Writer that writes data into a pipe.
|
2018-04-16 08:57:13 -04:00
|
|
|
type Writer struct {
|
|
|
|
pipe *pipe
|
|
|
|
}
|
|
|
|
|
2018-04-18 09:40:43 -04:00
|
|
|
// WriteMultiBuffer implements buf.Writer.
|
2018-04-16 08:57:13 -04:00
|
|
|
func (w *Writer) WriteMultiBuffer(mb buf.MultiBuffer) error {
|
|
|
|
return w.pipe.WriteMultiBuffer(mb)
|
|
|
|
}
|
|
|
|
|
2018-04-18 09:40:43 -04:00
|
|
|
// Close implements io.Closer. After the pipe is closed, writing to the pipe will return io.ErrClosedPipe, while reading will return io.EOF.
|
2018-04-16 08:57:13 -04:00
|
|
|
func (w *Writer) Close() error {
|
|
|
|
return w.pipe.Close()
|
|
|
|
}
|
|
|
|
|
2018-12-31 15:25:10 -05:00
|
|
|
// Interrupt implements common.Interruptible.
|
|
|
|
func (w *Writer) Interrupt() {
|
|
|
|
w.pipe.Interrupt()
|
2018-04-16 08:57:13 -04:00
|
|
|
}
|