bufpipe

package module
v0.0.0-...-8ac04dd Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2016 License: MIT Imports: 2 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

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

buffer is an io.ReadWriteCloser backed by a fixed size buffer. It never allocates, but moves old data as new data is written.

func (*Buffer) Close

func (b *Buffer) Close(err error)

Close marks the buffer as closed. Future calls to Write will return an error. Future calls to Read, once the buffer is empty, will return err.

func (*Buffer) Len

func (b *Buffer) Len() int

Len returns the number of bytes of the unread portion of the buffer.

func (*Buffer) Read

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

Read copies bytes from the buffer into p. It is an error to read when no data is available.

func (*Buffer) Write

func (b *Buffer) Write(p []byte) (n int, err error)

Write copies bytes from p into the buffer. It is an error to write more data than the buffer can hold.

type Pipe

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

func NewBufferedPipe

func NewBufferedPipe(size int) *Pipe

func (*Pipe) Close

func (c *Pipe) Close(err error)

func (*Pipe) Read

func (r *Pipe) Read(p []byte) (n int, err error)

Read waits until data is available and copies bytes from the buffer into p.

func (*Pipe) Write

func (w *Pipe) Write(p []byte) (n int, err error)

Write copies bytes from p into the buffer and wakes a reader. It is an error to write more data than the buffer can hold.

Jump to

Keyboard shortcuts

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