orio

package
v1.102.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Description: Implements a buffered writer that writes the last N bytes written to it

Description: Implements a writer that is limited to a specified number of bytes

Package orio implements IO utilities.

Index

Constants

This section is empty.

Variables

View Source
var ErrLimitExceeded = errors.New("size limit exceeded")

ErrLimitExceeded is returned if writes exceed the capacity.

Functions

This section is empty.

Types

type BufferedWriter

type BufferedWriter struct {
	N int
	// contains filtered or unexported fields
}

BufferedWriter buffers the last N bytes written to it.

It does not error if more writes happen but uses a circular buffer and keeps only the last N bytes.

Use Bytes() to access the buffer.

func (*BufferedWriter) Bytes

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

func (*BufferedWriter) Write

func (b *BufferedWriter) Write(p []byte) (int, error)

type Error

type Error struct {
	Err error
}

Error is a io.ReadWriteClose implementation that returns the underlying error for everything.

func (Error) Close

func (e Error) Close() error

func (Error) Read

func (e Error) Read(_ []byte) (int, error)

func (Error) Write

func (e Error) Write(_ []byte) (int, error)

type LimitedWriter

type LimitedWriter struct {
	N int
	// contains filtered or unexported fields
}

LimitedWriter limits write to a max of specified number of bytes.

It returns ErrLimitExceeded if the write exceeds this limit.

func (*LimitedWriter) Bytes

func (l *LimitedWriter) Bytes() []byte

func (*LimitedWriter) Write

func (l *LimitedWriter) Write(p []byte) (int, error)

type ReadCloser

type ReadCloser struct {
	io.Reader
	io.Closer
}

ReadCloser provides a simple way to create an io.ReadCloser by combining io.Reader and io.Closer

type WriteCloser

type WriteCloser struct {
	io.Writer
	io.Closer
}

WriteCloser provides a simple way to create an io.WriteCloser by combining io.Writer and io.Closer

Jump to

Keyboard shortcuts

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