mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-02 23:47:07 -05:00
comments
This commit is contained in:
parent
f5d76c8eb0
commit
1b6b39faad
@ -8,10 +8,12 @@ import (
|
|||||||
"v2ray.com/core/common/errors"
|
"v2ray.com/core/common/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// MultiBufferWriter is a writer that writes MultiBuffer.
|
||||||
type MultiBufferWriter interface {
|
type MultiBufferWriter interface {
|
||||||
WriteMultiBuffer(MultiBuffer) error
|
WriteMultiBuffer(MultiBuffer) error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MultiBufferReader is a reader that reader payload as MultiBuffer.
|
||||||
type MultiBufferReader interface {
|
type MultiBufferReader interface {
|
||||||
ReadMultiBuffer() (MultiBuffer, error)
|
ReadMultiBuffer() (MultiBuffer, error)
|
||||||
}
|
}
|
||||||
@ -60,14 +62,17 @@ func NewMultiBufferValue(b ...*Buffer) MultiBuffer {
|
|||||||
return MultiBuffer(b)
|
return MultiBuffer(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Append appends buffer to the end of this MultiBuffer
|
||||||
func (mb *MultiBuffer) Append(buf *Buffer) {
|
func (mb *MultiBuffer) Append(buf *Buffer) {
|
||||||
*mb = append(*mb, buf)
|
*mb = append(*mb, buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AppendMulti appends a MultiBuffer to the end of this one.
|
||||||
func (mb *MultiBuffer) AppendMulti(buf MultiBuffer) {
|
func (mb *MultiBuffer) AppendMulti(buf MultiBuffer) {
|
||||||
*mb = append(*mb, buf...)
|
*mb = append(*mb, buf...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Copy copied the begining part of the MultiBuffer into the given byte array.
|
||||||
func (mb MultiBuffer) Copy(b []byte) int {
|
func (mb MultiBuffer) Copy(b []byte) int {
|
||||||
total := 0
|
total := 0
|
||||||
for _, bb := range mb {
|
for _, bb := range mb {
|
||||||
@ -80,6 +85,7 @@ func (mb MultiBuffer) Copy(b []byte) int {
|
|||||||
return total
|
return total
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Read implements io.Reader.
|
||||||
func (mb *MultiBuffer) Read(b []byte) (int, error) {
|
func (mb *MultiBuffer) Read(b []byte) (int, error) {
|
||||||
endIndex := len(*mb)
|
endIndex := len(*mb)
|
||||||
totalBytes := 0
|
totalBytes := 0
|
||||||
@ -98,6 +104,7 @@ func (mb *MultiBuffer) Read(b []byte) (int, error) {
|
|||||||
return totalBytes, nil
|
return totalBytes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Write implements io.Writer.
|
||||||
func (mb *MultiBuffer) Write(b []byte) {
|
func (mb *MultiBuffer) Write(b []byte) {
|
||||||
n := len(*mb)
|
n := len(*mb)
|
||||||
if n > 0 && !(*mb)[n-1].IsFull() {
|
if n > 0 && !(*mb)[n-1].IsFull() {
|
||||||
|
Loading…
Reference in New Issue
Block a user