streams

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: Apache-2.0 Imports: 10 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrStreamTooLarge = errors.New("stream too large")

ErrStreamTooLarge is returned by LimitReadCloser when the stream is too large.

Functions

func LimitReadCloser

func LimitReadCloser(r io.ReadCloser, n int64) io.ReadCloser

LimitReadCloser returns a ReadCloser that reads from r but stops with ErrStreamTooLarge after n bytes.

func RuneToUppercase

func RuneToUppercase(c rune) []byte

RuneToUppercase converts a rune into a byte slice where all lowercase letters (Unicode-aware) are converted to uppercase ones.

func UppercaseTransformer

func UppercaseTransformer(r io.Reader) io.Reader

UppercaseTransformer uppercases all characters in the stream, by calling strings.ToUpper() on them.

Types

type MultiReaderCloser

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

MultiReaderCloser is an io.MultiReader that also implements the io.Closer interface to close the readable streams. Readable streams are also closed when we're done reading from them.

func NewMultiReaderCloser

func NewMultiReaderCloser(readers ...io.Reader) *MultiReaderCloser

NewMultiReaderCloser returns a stream that is like io.MultiReader but that can be closed. When the returned stream is closed, it closes the readable streams too, if they implement io.Closer.

func (*MultiReaderCloser) Close

func (mr *MultiReaderCloser) Close() error

Close implements io.Closer.

func (*MultiReaderCloser) Read

func (mr *MultiReaderCloser) Read(p []byte) (n int, err error)

func (*MultiReaderCloser) WriteTo

func (mr *MultiReaderCloser) WriteTo(w io.Writer) (sum int64, err error)

type TeeReadCloser

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

TeeReadCloser is an io.TeeReader that also implements the io.Closer interface to close the readable stream.

func NewTeeReadCloser

func NewTeeReadCloser(r io.Reader, w io.Writer) *TeeReadCloser

NewTeeReadCloser returns a stream that is like io.TeeReader but that can be closed. When the returned stream is closed, it closes the readable stream too, if it implements io.Closer.

func (*TeeReadCloser) Close

func (t *TeeReadCloser) Close() error

Close implements io.Closer.

func (*TeeReadCloser) Read

func (t *TeeReadCloser) Read(p []byte) (n int, err error)

Read from the R stream and tee it into the w stream.

func (*TeeReadCloser) Stop

func (t *TeeReadCloser) Stop() (err error)

Stop closes the underlying writer, which will blocks all future read operations with ErrClosedPipe, but doesn't close the reader stream. It's meant to be used when the reader needs to be swapped.

Jump to

Keyboard shortcuts

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