mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-01-05 16:55:27 -05:00
more doc
This commit is contained in:
@@ -6,20 +6,25 @@ import (
|
||||
"github.com/v2ray/v2ray-core/common/alloc"
|
||||
)
|
||||
|
||||
// Writer extends io.Writer with alloc.Buffer.
|
||||
type Writer interface {
|
||||
// Write writes an alloc.Buffer into underlying writer.
|
||||
Write(*alloc.Buffer) error
|
||||
}
|
||||
|
||||
// AdaptiveWriter is a Writer that writes alloc.Buffer into underlying writer.
|
||||
type AdaptiveWriter struct {
|
||||
writer io.Writer
|
||||
}
|
||||
|
||||
// NewAdaptiveWriter creates a new AdaptiveWriter.
|
||||
func NewAdaptiveWriter(writer io.Writer) *AdaptiveWriter {
|
||||
return &AdaptiveWriter{
|
||||
writer: writer,
|
||||
}
|
||||
}
|
||||
|
||||
// Write implements Writer.Write().
|
||||
func (this *AdaptiveWriter) Write(buffer *alloc.Buffer) error {
|
||||
nBytes, err := this.writer.Write(buffer.Value)
|
||||
if nBytes < buffer.Len() {
|
||||
|
||||
Reference in New Issue
Block a user