spb

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2024 License: GPL-3.0 Imports: 3 Imported by: 1

README

go-simple-protobuf

Golang implementation of simple-protobuf

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidStructLen = errors.New("invalid struct_len") // 1B<struct_len<1MB
	ErrInvalidDataLen   = errors.New("invalid data_len")
)

Functions

func ReadNum

func ReadNum(r io.Reader) (n uint32, cnt uint32, err error)

func WriteNum added in v0.2.0

func WriteNum(w io.Writer, n uint32) (cnt uint32, err error)

Types

type Constructor added in v0.2.0

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

func NewWriter added in v0.2.0

func NewWriter(buf []byte) (c Constructor)

NewWriter 新的写入构造器

func (*Constructor) Cap added in v0.2.0

func (c *Constructor) Cap() uint32

Cap structlen 目前写入的总长, 带 padding

func (*Constructor) Len added in v0.2.0

func (c *Constructor) Len() uint32

Len reallen 目前写入的实值总长, 不带 padding

func (*Constructor) WriteString added in v0.2.0

func (c *Constructor) WriteString(s string, cap uint32) error

WriteString 按字符串写入一项

func (*Constructor) WriteTo added in v0.2.0

func (c *Constructor) WriteTo(w io.Writer) (int64, error)

WriteTo 将当前结果写出, 返回写入的实际长度

type Iterator added in v0.2.0

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

func NewReader added in v0.2.0

func NewReader(r io.Reader) (it Iterator, err error)

NewReader 迭代器形式读取而非一次解析完

func (*Iterator) Bytes added in v0.2.0

func (it *Iterator) Bytes() []byte

Bytes 本次迭代的原始值

func (*Iterator) Cap added in v0.2.0

func (it *Iterator) Cap() uint32

Cap structlen 结构体带 padding 的长度

func (*Iterator) Len added in v0.2.0

func (it *Iterator) Len() uint32

Len reallen (迭代器目前迭代到的实值总长, 不带 padding)

func (*Iterator) Next added in v0.2.0

func (it *Iterator) Next() bool

Next 是否有下一个

func (*Iterator) String added in v0.2.0

func (it *Iterator) String() string

String 将本次迭代的值解释为 string

type SimplePB

type SimplePB struct {
	StructLen, RealLen uint32
	Target             [][]byte
}

func NewSimplePB

func NewSimplePB(r io.Reader) (s SimplePB, err error)

Jump to

Keyboard shortcuts

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