procreader

package
v0.0.0-...-3fa40c8 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2023 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package procreader provides a ProcReader object that implements the io.Reader interface and generates its data from a user-specified callback function.

Use the New function to create a new ProcReader and pass it a callback function that is invoked to create new data when the ProcReader's buffers are empty.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callback

type Callback func(size int) ([]byte, error)

Callback is a callback function that generates data in the form of a slice of bytes. Size is a hint as to how much data is requested. If the callback returns more data, the excess will be buffered by the reader for subsequent Read calls. If no data is left, the Callback function must returns an io.EOF error.

type ProcReader

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

ProcReader is a procedural reader that generates its data from a callback function.

func New

func New(callback Callback) *ProcReader

New creates a new ProcReader.

func (*ProcReader) Read

func (r *ProcReader) Read(p []byte) (int, error)

Read requests data from the callback until either the buffer is full, or an error like EOF occurs.

Jump to

Keyboard shortcuts

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