mirror of
https://github.com/SagerNet/sing.git
synced 2025-04-03 20:07:38 +03:00
34 lines
436 B
Go
34 lines
436 B
Go
package varbin
|
|
|
|
import (
|
|
"io"
|
|
)
|
|
|
|
type Reader interface {
|
|
io.Reader
|
|
io.ByteReader
|
|
}
|
|
|
|
type Writer interface {
|
|
io.Writer
|
|
io.ByteWriter
|
|
}
|
|
|
|
var _ Reader = stubReader{}
|
|
|
|
func StubReader(reader io.Reader) Reader {
|
|
if r, ok := reader.(Reader); ok {
|
|
return r
|
|
}
|
|
return stubReader{reader}
|
|
}
|
|
|
|
type stubReader struct {
|
|
io.Reader
|
|
}
|
|
|
|
func (r stubReader) ReadByte() (byte, error) {
|
|
var b [1]byte
|
|
_, err := r.Read(b[:])
|
|
return b[0], err
|
|
}
|