1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-29 18:45:23 +00:00
This commit is contained in:
Darien Raymond 2017-11-08 18:14:44 +01:00
parent 9cc9a76b71
commit 2a96aaaf7b
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
3 changed files with 7 additions and 1 deletions

View File

@ -14,6 +14,7 @@ type Reader interface {
// ErrReadTimeout is an error that happens with IO timeout.
var ErrReadTimeout = newError("IO timeout")
// TimeoutReader is a reader that returns error if Read() operation takes longer than the given timeout.
type TimeoutReader interface {
ReadTimeout(time.Duration) (MultiBuffer, error)
}

View File

@ -161,6 +161,7 @@ func (mb MultiBuffer) ToNetBuffers() net.Buffers {
return bs
}
// SliceBySize splits the begining of this MultiBuffer into another one, for at most size bytes.
func (mb *MultiBuffer) SliceBySize(size int) MultiBuffer {
slice := NewMultiBuffer()
sliceSize := 0
@ -178,6 +179,7 @@ func (mb *MultiBuffer) SliceBySize(size int) MultiBuffer {
return slice
}
// SplitFirst splits out the first Buffer in this MultiBuffer.
func (mb *MultiBuffer) SplitFirst() *Buffer {
if len(*mb) == 0 {
return nil

View File

@ -137,6 +137,9 @@ func (noOpBytesWriter) ReadFrom(reader io.Reader) (int64, error) {
}
var (
Discard Writer = noOpWriter{}
// Discard is a Writer that swallows all contents written in.
Discard Writer = noOpWriter{}
// DiscardBytes is an io.Writer that swallows all contents written in.
DiscardBytes io.Writer = noOpBytesWriter{}
)