stream

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SEEK_SET int = 0 // seek relative to the origin of the file
	SEEK_CUR int = 1 // seek relative to the current offset
	SEEK_END int = 2 // seek relative to the end
)

Variables

This section is empty.

Functions

func CalcSize

func CalcSize(content interface{}) int

CalcSize 计算序列化所需长度

Types

type ByteStream

type ByteStream struct {
	// contains filtered or unexported fields
}

ByteStream 包装一些字节流的读写方法,方便二进制消息的序列和反序列

func NewByteStream

func NewByteStream(data []byte) *ByteStream

NewByteStream 创建一个新的字节流

func NewDefaultByteStream

func NewDefaultByteStream() *ByteStream

func (*ByteStream) GetUsedData

func (bs *ByteStream) GetUsedData() []byte

GetUsedSlice 获取已经写入的部分Slice

func (*ByteStream) Len

func (bs *ByteStream) Len() uint64

获取使用的数据长度

func (*ByteStream) Marshal

func (bs *ByteStream) Marshal(content interface{}) error

Marshal 序列化content

func (*ByteStream) ReadBool

func (bs *ByteStream) ReadBool() (bool, error)

ReadBool 读bool

func (*ByteStream) ReadByte

func (bs *ByteStream) ReadByte() (byte, error)

ReadByte 读取一个字节

func (*ByteStream) ReadBytes

func (bs *ByteStream) ReadBytes() ([]byte, error)

ReadBytes 读取一个byte[]

func (*ByteStream) ReadEnd

func (bs *ByteStream) ReadEnd() bool

ReadEnd 是否读完

func (*ByteStream) ReadFloat32

func (bs *ByteStream) ReadFloat32() (float32, error)

ReadFloat32 读取float32

func (*ByteStream) ReadFloat64

func (bs *ByteStream) ReadFloat64() (float64, error)

ReadFloat64 读取float64

func (*ByteStream) ReadInt16

func (bs *ByteStream) ReadInt16() (int16, error)

ReadInt16 读取一个int16

func (*ByteStream) ReadInt32

func (bs *ByteStream) ReadInt32() (int32, error)

ReadInt32 读取一个int32

func (*ByteStream) ReadInt64

func (bs *ByteStream) ReadInt64() (int64, error)

ReadInt64 读取一个int64

func (*ByteStream) ReadInt8

func (bs *ByteStream) ReadInt8() (int8, error)

ReadInt8 读取一个int8

func (*ByteStream) ReadString

func (bs *ByteStream) ReadString() (string, error)

ReadString 读取一个string

func (*ByteStream) ReadUint16

func (bs *ByteStream) ReadUint16() (uint16, error)

ReadUInt16 读取一个UInt16

func (*ByteStream) ReadUint32

func (bs *ByteStream) ReadUint32() (uint32, error)

ReadUInt32 读取一个Int

func (*ByteStream) ReadUint64

func (bs *ByteStream) ReadUint64() (uint64, error)

ReadUInt64 读取一个Uint64

func (*ByteStream) Reset

func (bs *ByteStream) Reset(data []byte)

func (*ByteStream) Seek

func (bs *ByteStream) Seek(offset int64, whence int)

func (*ByteStream) Unmarshal

func (bs *ByteStream) Unmarshal(content interface{}) error

Unmarshal 反序列化

func (*ByteStream) WriteBool

func (bs *ByteStream) WriteBool(v bool) error

WriteBool 写bool, 1代表true, 0代表false

func (*ByteStream) WriteByte

func (bs *ByteStream) WriteByte(v byte) error

WriteByte 写字节

func (*ByteStream) WriteBytes

func (bs *ByteStream) WriteBytes(v []byte) error

WriteBytes 写[]byte

func (*ByteStream) WriteFloat32

func (bs *ByteStream) WriteFloat32(f float32) error

WriteFloat32 写Float32

func (*ByteStream) WriteFloat64

func (bs *ByteStream) WriteFloat64(f float64) error

WriteFloat64 写Float64

func (*ByteStream) WriteInt16

func (bs *ByteStream) WriteInt16(v int16) error

WriteInt16 写Int16

func (*ByteStream) WriteInt32

func (bs *ByteStream) WriteInt32(v int32) error

WriteInt32 写Int32

func (*ByteStream) WriteInt64

func (bs *ByteStream) WriteInt64(v int64) error

WriteInt64 写Int64

func (*ByteStream) WriteInt8

func (bs *ByteStream) WriteInt8(v int8) error

WriteInt8 写Int8

func (*ByteStream) WriteMap

func (bs *ByteStream) WriteMap(val map[uint32]uint32) error

func (*ByteStream) WriteRawBytes

func (bs *ByteStream) WriteRawBytes(v []byte) error

func (*ByteStream) WriteString

func (bs *ByteStream) WriteString(v string) error

WriteString 写string

func (*ByteStream) WriteUint16

func (bs *ByteStream) WriteUint16(v uint16) error

WriteUInt16 写Uint16

func (*ByteStream) WriteUint32

func (bs *ByteStream) WriteUint32(v uint32) error

WriteUInt32 写Uint32

func (*ByteStream) WriteUint64

func (bs *ByteStream) WriteUint64(v uint64) error

WriteUInt64 写Uint64

func (*ByteStream) WriteUint8

func (bs *ByteStream) WriteUint8(v uint8) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL