io

package
v0.0.0-...-0fefa07 Latest Latest
Warning

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

Go to latest
Published: May 13, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Newline character
	NL = '\n'
	// Carriage Return character
	CR = '\r'
)

Variables

This section is empty.

Functions

func CalculateChecksum

func CalculateChecksum(r libio.Reader) (uint32, error)

func NewReadWriter

func NewReadWriter(r libio.Reader, w libio.Writer) libio.ReadWriter

NewReadWriter create as new io.ReadWriter instance using the given read and writer instance.

func Peek

func Peek(p []byte, n int) byte

func ReadConfirmation

func ReadConfirmation(prompt string, src libio.Reader, dst libio.Writer) (choice bool, err error)

func ReadOsConfirmation

func ReadOsConfirmation(prompt string) (bool, error)

func ScanLines

func ScanLines(data []byte, atEOF bool) (advance int, token []byte, err error)

ScanLines is a splitter function for a bufio.Scanner instance. it is the same implementation as the one from the golang library, except it preserves the terminating newline characters

func SeekPrefixedLinesEnd

func SeekPrefixedLinesEnd(r libio.Reader, prefix []byte) (int64, error)

SeekPrefixedLinesEnd reads lines from the provided reader and adds up their length if they are prefixed. The resulting byte count is the seek position from the start to skip the affected lines. Lines not starting with the prefix stop the search. Any error is from the underlying reader.

Types

type PrefixScanner

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

func NewPrefixScanner

func NewPrefixScanner(reader libio.Reader, prefix []byte) *PrefixScanner

func (*PrefixScanner) Next

func (r *PrefixScanner) Next() ([]byte, error)

type PrefixWriter

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

func NewPrefixWriter

func NewPrefixWriter(writer libio.Writer, prefix []byte) *PrefixWriter

func (*PrefixWriter) Write

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

type ReadWriter

type ReadWriter struct {
	libio.Reader
	libio.Writer
}

ReadWriter implements the io.ReadWriter interface. in comparison to bufio.ReadWriter, this implementation is completly unbuffered; all calls are passed on directly.

Jump to

Keyboard shortcuts

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