pipe

package
v1.8.8 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: Apache-2.0 Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FixedBuffer

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

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

func NewFixedBuffer

func NewFixedBuffer(buf []byte) *FixedBuffer

func (*FixedBuffer) Len

func (b *FixedBuffer) Len() int

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

func (*FixedBuffer) Read

func (b *FixedBuffer) 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 (*FixedBuffer) Reset

func (b *FixedBuffer) Reset()

Reset clear state of FixedBuffer.

func (*FixedBuffer) Write

func (b *FixedBuffer) 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
}

Pipe is a goroutine-safe io.Reader/io.Writer pair. It's like io.Pipe except there are no PipeReader/PipeWriter halves, and the underlying buffer is an interface. (io.Pipe is always unbuffered)

func NewPipeFromBufferPool

func NewPipeFromBufferPool(pool *sync.Pool) *Pipe

func NewPipeWithSize

func NewPipeWithSize(size uint32) *Pipe

func (*Pipe) BreakWithError

func (p *Pipe) BreakWithError(err error)

BreakWithError causes the next Read (waking up a current blocked Read if needed) to return the provided err immediately, without waiting for unread data.

func (*Pipe) CloseWithError

func (p *Pipe) CloseWithError(err error)

CloseWithError causes the next Read (waking up a current blocked Read if needed) to return the provided err after all data has been read.

The error must be non-nil.

func (*Pipe) CloseWithErrorAndCode

func (p *Pipe) CloseWithErrorAndCode(err error, fn func())

CloseWithErrorAndCode is like CloseWithError but also sets some code to run in the caller's goroutine before returning the error.

func (*Pipe) Done

func (p *Pipe) Done() <-chan struct{}

Done returns a channel which is closed if and when this pipe is closed with CloseWithError.

func (*Pipe) Err

func (p *Pipe) Err() error

Err returns the error (if any) first set by BreakWithError or CloseWithError.

func (*Pipe) Read

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

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

func (*Pipe) Release

func (p *Pipe) Release(pool *sync.Pool)

Release releases underlying fixed buffer

func (*Pipe) Write

func (p *Pipe) Write(d []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.

type PipeBuffer

type PipeBuffer interface {
	Len() int
	Reset()
	io.Writer
	io.Reader
}

Jump to

Keyboard shortcuts

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