filesharing

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const FileType = "nimona.io/File"
View Source
const TransferDoneType = "nimona.io/TransferDone"
View Source
const TransferRequestType = "nimona.io/TransferRequest"
View Source
const TransferResponseType = "nimona.io/TransferResponse"

Variables

View Source
var ErrTransferRejected = errors.New("transfer rejected")

Functions

This section is empty.

Types

type File

type File struct {
	Metadata object.Metadata `nimona:"@metadata:m,type=nimona.io/File"`
	Name     string          `nimona:"name:s"`
	Chunks   []tilde.Digest  `nimona:"chunks:as"`
}

type Filesharer

type Filesharer interface {
	Listen(
		ctx context.Context,
	) (
		chan *Transfer,
		error,
	)
	RequestTransfer(
		ctx context.Context,
		file *File,
		peerKey crypto.PublicKey,
	) (string, error)
	RespondTransfer(
		ctx context.Context,
		transfer Transfer,
		accepted bool,
	) error
	RequestFile(
		ctx context.Context,
		transfer *Transfer,
	) (
		*os.File,
		error,
	)
}

func New

func New(
	objectManager objectmanager.ObjectManager,
	net network.Network,
	receivedFolder string,
) Filesharer

type Transfer

type Transfer struct {
	Request TransferRequest
	Peer    crypto.PublicKey
}

type TransferDone

type TransferDone struct {
	Metadata object.Metadata `nimona:"@metadata:m,type=nimona.io/TransferDone"`
	Nonce    string          `nimona:"nonce:s"`
}

type TransferRequest

type TransferRequest struct {
	Metadata object.Metadata `nimona:"@metadata:m,type=nimona.io/TransferRequest"`
	File     File            `nimona:"file:m"`
	Nonce    string          `nimona:"nonce:s"`
}

type TransferResponse

type TransferResponse struct {
	Metadata object.Metadata `nimona:"@metadata:m,type=nimona.io/TransferResponse"`
	Nonce    string          `nimona:"nonce:s"`
	Accepted bool            `nimona:"accepted:b"`
}

Jump to

Keyboard shortcuts

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