circle

package
v0.41.8 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2020 License: MIT Imports: 2 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTooManyToWrite 内容太长,无法写入
	ErrTooManyToWrite = errors.New("too many data to write")
	// ErrInvalidBuffer 用于读取的 buffer 无效
	ErrInvalidBuffer = errors.New("invalid buffer")
	// ErrNotEnough 数据不足以读取长度 n 的内容
	ErrNotEnough = errors.New("not enough data")
	// ErrInvalidSkipSize 无效的长度
	ErrInvalidSkipSize = errors.New("invalid skip size")
	// ErrIsFull 缓冲区已满
	ErrIsFull = errors.New("buffer is full")
	// ErrIsEmpty 缓冲区已满
	ErrIsEmpty = errors.New("buffer is empty")
	// ErrInvalidLength 无效长度
	ErrInvalidLength = errors.New("invalid length")
)

Functions

This section is empty.

Types

type Circle

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

Circle 环形结构

func New

func New(size int) *Circle

New 创建环形结构

func (*Circle) Cap

func (c *Circle) Cap() int

Cap ..

func (*Circle) Free

func (c *Circle) Free() int

Free 剩余空间

func (*Circle) Get added in v0.4.1

func (c *Circle) Get(n int) ([]byte, error)

Get 获取缓冲中的数据

func (*Circle) IsEmpty added in v0.3.1

func (c *Circle) IsEmpty() bool

IsEmpty 缓冲区是否为空

func (*Circle) IsFull added in v0.3.1

func (c *Circle) IsFull() bool

IsFull 缓冲区是否已满

func (*Circle) Len

func (c *Circle) Len() int

Len 有效 buffer 的长度

func (*Circle) Peek added in v0.3.1

func (c *Circle) Peek(n int) ([]byte, error)

Peek 读取 n 个长度的内容,但不会产生任何影响 不会改变 c.read 和 c.write

func (*Circle) Read

func (c *Circle) Read(p []byte) (int, error)

Read 读取尽量多的数据到 p 中 p: 数据会拷贝到 p 中 n: 读取到 P 中的数据长度

func (*Circle) ReadN

func (c *Circle) ReadN(n int, p []byte) error

ReadN 读取长度 n 的内容到 p 中 只存在读取了长度 n 的内容到 p 中,和 一点都不读取两种情况 不存在只读了部分(< n) 的内容到 p 中的情况

func (*Circle) Reset added in v0.3.1

func (c *Circle) Reset()

Reset 重置

func (*Circle) Skip added in v0.3.1

func (c *Circle) Skip(n int) error

Skip 跳过 n 个字段,会改变 c.read

func (*Circle) String

func (c *Circle) String() string

func (*Circle) Write

func (c *Circle) Write(p []byte) (int, error)

Write 写入数据 只有全部写入,或者都不写入两种情况,不存在只写入一部分的情形

func (*Circle) WriteN added in v0.7.1

func (c *Circle) WriteN(p []byte, n int) error

WriteN 写入长度为 n 的数据

Jump to

Keyboard shortcuts

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