bufio

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBufferFull err buffer full
	ErrBufferFull = bufio.ErrBufferFull
)

Functions

func Put

func Put(b *Buffer)

Put the data into global pool

Types

type Buffer

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

Buffer buffer.

func Get

func Get(size int) *Buffer

Get the data buffer

func NewBuffer

func NewBuffer(size int) *Buffer

NewBuffer new buffer.

func (*Buffer) Advance

func (b *Buffer) Advance(n int)

Advance the rpos

func (*Buffer) Bytes

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

Bytes return the bytes readed

func (*Buffer) Reset

func (b *Buffer) Reset()

Reset reset buffer.

type Reader

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

Reader implements buffering for an io.Reader object.

func NewReader

func NewReader(rd io.Reader, b *Buffer) *Reader

NewReader returns a new Reader whose buffer has the default size.

func (*Reader) Advance

func (r *Reader) Advance(n int)

Advance proxy to buffer advance

func (*Reader) AdvanceTo

func (r *Reader) AdvanceTo(mark int)

AdvanceTo reset buffer read pos.

func (*Reader) Buffer

func (r *Reader) Buffer() *Buffer

Buffer will return the reference of local buffer

func (*Reader) Mark

func (r *Reader) Mark() int

Mark return buf read pos.

func (*Reader) Read

func (r *Reader) Read() error

Read will trying to read until the buffer is full

func (*Reader) ReadExact

func (r *Reader) ReadExact(n int) (data []byte, err error)

ReadExact will read n size bytes or return ErrBufferFull. It never contains any I/O operation

func (*Reader) ReadLine

func (r *Reader) ReadLine() (line []byte, err error)

ReadLine will read until meet the first crlf bytes.

func (*Reader) ReadSlice

func (r *Reader) ReadSlice(delim byte) (data []byte, err error)

ReadSlice will read until the delim or return ErrBufferFull. It never contains any I/O operation

type Writer

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

Writer implements buffering for an io.Writer object. If an error occurs writing to a Writer, no more data will be accepted and all subsequent writes, and Flush, will return the error. After all data has been written, the client should call the Flush method to guarantee all data has been forwarded to the underlying io.Writer.

func NewWriter

func NewWriter(wr *libnet.Conn) *Writer

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

func (*Writer) Flush

func (w *Writer) Flush() error

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

func (*Writer) Write

func (w *Writer) Write(p []byte) (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