bpool

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buff

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

func New

func New(size int) *Buff

func NewBuf

func NewBuf(buf []byte) *Buff

func ReadAll

func ReadAll(r io.Reader, size int) (bp *Buff, err error)

func (*Buff) Append

func (b *Buff) Append(buf ...byte) *Buff

func (*Buff) Cap

func (b *Buff) Cap() int

func (*Buff) Copy

func (b *Buff) Copy() (buf []byte)

func (*Buff) Free

func (b *Buff) Free()

调用该方法后,不能继续使用buff,否则有不可预料的bug

func (*Buff) Read

func (b *Buff) Read(r io.Reader, size int) (n int, err error)

func (*Buff) Reset

func (b *Buff) Reset()

func (*Buff) SetSize

func (b *Buff) SetSize(size int)

func (*Buff) Size

func (b *Buff) Size() int

func (*Buff) ToBytes

func (b *Buff) ToBytes() []byte

type Writer

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

func NewWriter

func NewWriter(w io.Writer) *Writer

NewWriter returns a new Writer whose buffer has the default size.

func NewWriterSize

func NewWriterSize(w io.Writer, size int) *Writer

NewWriterSize returns a new Writer whose buffer has at least the specified size, it returns the underlying Writer.

func (*Writer) Available

func (b *Writer) Available() int

Available returns how many bytes are unused in the buffer.

func (*Writer) Buffered

func (b *Writer) Buffered() int

Buffered returns the number of bytes that have been written into the current buffer.

func (*Writer) Flush

func (b *Writer) Flush() error

Flush writes any buffered data to the underlying io.Writer.

func (*Writer) Free

func (b *Writer) Free()

func (*Writer) Reset

func (b *Writer) Reset(w io.Writer)

Reset discards any unflushed buffered data, clears any error, and resets b to write its output to w.

func (*Writer) Size

func (b *Writer) Size() int

Size returns the size of the underlying buffer in bytes.

func (*Writer) Write

func (b *Writer) Write(p []byte) (nn int, err error)

Write writes the contents of p into the buffer. It returns the number of bytes written. If nn < len(p), it also returns an error explaining why the write is short.

Jump to

Keyboard shortcuts

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