2020-11-25 13:01:53 +02:00
|
|
|
package pipe
|
|
|
|
|
|
|
|
import (
|
2020-12-04 03:36:16 +02:00
|
|
|
"github.com/xtls/xray-core/common/buf"
|
2020-11-25 13:01:53 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// Writer is a buf.Writer that writes data into a pipe.
|
|
|
|
type Writer struct {
|
|
|
|
pipe *pipe
|
|
|
|
}
|
|
|
|
|
|
|
|
// WriteMultiBuffer implements buf.Writer.
|
|
|
|
func (w *Writer) WriteMultiBuffer(mb buf.MultiBuffer) error {
|
|
|
|
return w.pipe.WriteMultiBuffer(mb)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Close implements io.Closer. After the pipe is closed, writing to the pipe will return io.ErrClosedPipe, while reading will return io.EOF.
|
|
|
|
func (w *Writer) Close() error {
|
|
|
|
return w.pipe.Close()
|
|
|
|
}
|
|
|
|
|
2024-08-17 14:01:58 +03:00
|
|
|
func (w *Writer) Len() int32 {
|
2024-11-09 13:16:11 +02:00
|
|
|
return w.pipe.Len()
|
2024-08-17 14:01:58 +03:00
|
|
|
}
|
|
|
|
|
2020-11-25 13:01:53 +02:00
|
|
|
// Interrupt implements common.Interruptible.
|
|
|
|
func (w *Writer) Interrupt() {
|
|
|
|
w.pipe.Interrupt()
|
|
|
|
}
|