trzsz

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: AGPL-3.0 Imports: 16 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 trzsz is the client side of trzsz (trzsz.github.io): when trz or tsz on the server prints its magic, Find spots it, Send gives trz the files it waits for and Receive takes those tsz sends. It speaks the protocol's first version, in base64, which every server takes, and draws nothing: the caller asks the user and shows how it goes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Receive

func Receive(ctx context.Context, c xfer.Conn, o *Offer, sink xfer.Sink, opt Options) (rest []byte, err error)

Receive takes the files of a Download offer, and its folders, into sink. It returns what the shell printed after the transfer.

func Refuse

func Refuse(ctx context.Context, c xfer.Conn, o *Offer) (rest []byte, err error)

Refuse tells the server the user chose nothing, and it ends.

func Send

func Send(ctx context.Context, c xfer.Conn, o *Offer, src xfer.Source, opt Options) (rest []byte, err error)

Send gives an Upload or UploadDir offer src's files, and its folders for UploadDir.

Types

type Mode

type Mode int

Mode is what the server asks for.

const (
	// Download is tsz: the server sends files.
	Download Mode = iota
	// Upload is trz: the server waits for files.
	Upload
	// UploadDir is trz -d: the server waits for files and folders.
	UploadDir
)

type Offer

type Offer struct {
	Mode Mode
	// Version is the server's trzsz version.
	Version string
	// ID is the transfer's unique id; a terminal redrawn may show the
	// magic again, with the same id.
	ID string
	// Windows is a server on Windows, whose console mangles lines.
	Windows bool
	// Tmux is a server inside tmux, which adds to what it prints.
	Tmux bool
}

Offer is a transfer the server started, as its magic said.

func Find

func Find(p []byte) (at int, o *Offer)

Find reports where in p a transfer starts, just after the line of its magic, -1 and nil for none: the magic of a transfer already over, shown again, does not count, nor one whose line has not all come.

type Options

type Options struct {
	// Progress is told how the files go; nil for nothing.
	Progress xfer.Progress
	// Saved is what the server prints once the files came: n of them,
	// in dir. nil says it in English.
	Saved func(n int, dir string) string
	// Dir is where received files go, for Saved.
	Dir string
}

Options are how a transfer goes.

Jump to

Keyboard shortcuts

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