fixedreader

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: Apache-2.0 Imports: 2 Imported by: 1

Documentation

Overview

Copyright 2021-2024 antlabs. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FixedReader

type FixedReader struct {
	R, W int // buf read and write positions
	// contains filtered or unexported fields
}

固定大小的FixedReader, 所有的内存都是提前分配好的 标准库的bufio.Reader不能自定义buf传过去, 导致控制力度会差点

func NewFixedReader

func NewFixedReader(r io.Reader, buf *[]byte) *FixedReader

newBuffer returns a new Buffer whose buffer has the specified size.

func (*FixedReader) Available

func (b *FixedReader) Available() int64

返回剩余可用的缓存区大小

func (*FixedReader) BufPtr added in v0.0.8

func (b *FixedReader) BufPtr() *[]byte

func (*FixedReader) Buffered

func (b *FixedReader) Buffered() int

func (*FixedReader) Bytes

func (b *FixedReader) Bytes() []byte

func (*FixedReader) CloneAvailable

func (b *FixedReader) CloneAvailable() *FixedReader

func (*FixedReader) Init added in v0.0.8

func (b *FixedReader) Init(r io.Reader, buf *[]byte)

func (*FixedReader) IsInit added in v0.0.8

func (b *FixedReader) IsInit() bool

func (*FixedReader) LeftMove

func (b *FixedReader) LeftMove()

左移缓存区

func (*FixedReader) Len

func (b *FixedReader) Len() int

返回底层[]byte的长度

func (*FixedReader) Read

func (b *FixedReader) Read(p []byte) (n int, err error)

这和一般read接口中不一样 传入的p 一定会满足这个大小

func (*FixedReader) ReadN added in v0.1.2

func (b *FixedReader) ReadN(n int) (rvn int, err error)

func (*FixedReader) Release

func (b *FixedReader) Release() error

func (*FixedReader) Reset

func (b *FixedReader) Reset(buf *[]byte)

将缓存区重置为一个新的buf

func (*FixedReader) ResetReader added in v0.0.6

func (b *FixedReader) ResetReader(r io.Reader)

func (*FixedReader) WriteCap

func (b *FixedReader) WriteCap() int

返回剩余可写的缓存区大小

func (*FixedReader) WriteCapBytes

func (b *FixedReader) WriteCapBytes() []byte

返回可写的缓存区

Jump to

Keyboard shortcuts

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