boxio

package
v0.0.0-...-fefb07e Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: Apache-2.0 Imports: 5 Imported by: 2

Documentation

Index

Constants

View Source
const MessageSizeMax = 1 << 22 // 4 MB

MessageSizeMax is a soft (recommended) maximum for network messages. One can write more, as the interface is a stream. But it is useful to bunch it up into multiple read/writes when the whole message is a single, large serialized object.

Variables

View Source
var (
	BoxMsgIO = &BoxDataIOData{}
)

Functions

func ReadBool

func ReadBool(buff *bytes.Buffer) (bool, error)

func ReadData

func ReadData(buff *bytes.Buffer, numType NumType) ([]byte, error)

ReadData 读一个极小块数据,块级别,tiny uint8,small uint16,normal uint32,big uint64;

func ReadString

func ReadString(buff *bytes.Buffer, numType NumType) (string, error)

func WriteBool

func WriteBool(buff *bytes.Buffer, b bool) error

func WriteData

func WriteData(buff *bytes.Buffer, data []byte, numType NumType) error

WriteData 块级别,tiny uint8,small uint16,normal uint32,big uint64;

Types

type BoxData

type BoxData interface {
	Unmarshal(data []byte) error
	Marshal() ([]byte, error)
	Size() int
	Tag() string
}

type BoxDataIOData

type BoxDataIOData struct {
}

func (*BoxDataIOData) ReadMessage

func (that *BoxDataIOData) ReadMessage(stream io.Reader, msg BoxData) error

ReadMessage 读取一个BoxData消息

func (*BoxDataIOData) WriteMessage

func (that *BoxDataIOData) WriteMessage(stream io.Writer, msg BoxData, tryCount int) error

type BoxReader

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

func (*BoxReader) Close

func (that *BoxReader) Close() error

func (*BoxReader) ReadBox

func (that *BoxReader) ReadBox(d BoxData) error

type BoxWriter

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

func (*BoxWriter) Close

func (that *BoxWriter) Close() error

func (*BoxWriter) WriteBox

func (that *BoxWriter) WriteBox(d BoxData) error

type NumType

type NumType uint8
const (
	Num8  NumType = 8  //1个字节
	Num16 NumType = 16 // 2个字节
	Num32 NumType = 32 // 4个字节
	Num64 NumType = 64 // 8个字节
)

type ReadCloser

type ReadCloser interface {
	Reader
	io.Closer
}

func NewBoxReader

func NewBoxReader(r io.Reader, maxSize int) ReadCloser

type Reader

type Reader interface {
	ReadBox(block BoxData) error
}

type WriteCloser

type WriteCloser interface {
	Writer
	io.Closer
}

func NewBoxWriter

func NewBoxWriter(w io.Writer) WriteCloser

type Writer

type Writer interface {
	WriteBox(BoxData) error
}

Jump to

Keyboard shortcuts

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