xfertest

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0 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

Overview

Package xfertest has what tests of transfers over a terminal use: both ends of a byte stream, and files kept in memory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type End

type End struct {

	// Tamper, when set, changes what this end writes on its way.
	Tamper func(p []byte) []byte
	// Wrote is all this end wrote, as it went out.
	Wrote bytes.Buffer
	// contains filtered or unexported fields
}

End is one end of a Pipe.

func Pipe

func Pipe() (a, b *End)

Pipe returns both ends of a stream: what one writes, the other reads.

func (*End) Close

func (e *End) Close() []byte

Close ends what this end reads, returning what it left unread.

func (*End) Read

func (e *End) Read(p []byte) (int, error)

func (*End) SetReadDeadline

func (e *End) SetReadDeadline(t time.Time) error

func (*End) Write

func (e *End) Write(p []byte) (int, error)

type Item

type Item struct {
	File xfer.File
	Data []byte
}

Item is a file or folder a Source sends.

type Sink

type Sink struct {

	// Files are those committed, by name.
	Files map[string][]byte
	// Dirs are the folders made.
	Dirs []string
	// Info is what was said of each file created.
	Info []xfer.File
	// Aborted counts the files dropped.
	Aborted int
	// Skip names files to skip; Fail fails Create for every file.
	Skip map[string]bool
	Fail error
	// Rename gives the local name of a file, when set.
	Rename func(name string) string
	// contains filtered or unexported fields
}

Sink keeps received files in memory.

func (*Sink) Committed

func (s *Sink) Committed() []string

Committed returns the names of the files committed, sorted.

func (*Sink) Create

func (s *Sink) Create(f xfer.File) (string, xfer.Writer, error)

type Source

type Source struct {
	Items []Item
	// Opened counts the files opened.
	Opened int
}

Source sends Items in order, their content seekable.

func (*Source) Files

func (s *Source) Files() []xfer.File

func (*Source) Open

func (s *Source) Open(i int) (io.ReadCloser, error)

Jump to

Keyboard shortcuts

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