1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-12-30 22:15:27 -05:00

refactor io package

This commit is contained in:
Darien Raymond
2016-12-09 13:17:34 +01:00
parent 055023fdd5
commit 1948d0738f
36 changed files with 390 additions and 414 deletions

View File

@@ -1,10 +1,6 @@
package serial
import (
"strconv"
"v2ray.com/core/common/buf"
)
import "strconv"
func Uint16ToBytes(value uint16, b []byte) []byte {
return append(b, byte(value>>8), byte(value))
@@ -14,7 +10,7 @@ func Uint16ToString(value uint16) string {
return strconv.Itoa(int(value))
}
func WriteUint16(value uint16) buf.Supplier {
func WriteUint16(value uint16) func([]byte) (int, error) {
return func(b []byte) (int, error) {
b = Uint16ToBytes(value, b[:0])
return 2, nil
@@ -29,7 +25,7 @@ func Uint32ToString(value uint32) string {
return strconv.FormatUint(uint64(value), 10)
}
func WriteUint32(value uint32) buf.Supplier {
func WriteUint32(value uint32) func([]byte) (int, error) {
return func(b []byte) (int, error) {
b = Uint32ToBytes(value, b[:0])
return 4, nil