file

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2020 License: BSD-3-Clause Imports: 7 Imported by: 7

Documentation

Overview

Package file provides interfaces for file-oriented operations.

Index

Constants

This section is empty.

Variables

View Source
var Spans []int64

Functions

func GenerateSpanSizes

func GenerateSpanSizes(levels, branches int) []int64

GenerateSpanSizes generates a dictionary of maximum span lengths per level represented by one SectionSize() of data

func JoinReadAll

func JoinReadAll(ctx context.Context, j JoinSeeker, addr swarm.Address, outFile io.Writer) (int64, error)

JoinReadAll reads all output from the provided SeekJoiner.

func Levels

func Levels(length int64, sectionSize, branches int) int

Levels calculates the last level index which a particular data section count will result in. The returned level will be the level of the root hash.

func NewAbortError

func NewAbortError(err error) error

NewAbortError creates a new AbortError instance.

func NewChunkPipe

func NewChunkPipe() io.ReadWriteCloser

Creates a new ChunkPipe

func NewHashError

func NewHashError(err error) error

NewHashError creates a new HashError instance.

func NewSimpleReadCloser

func NewSimpleReadCloser(buffer []byte) io.ReadCloser

NewSimpleReadCloser creates a new simpleReadCloser.

func SplitWriteAll

func SplitWriteAll(ctx context.Context, s Splitter, r io.Reader, l int64, toEncrypt bool) (swarm.Address, error)

SplitWriteAll writes all input from provided reader to the provided splitter

Types

type AbortError

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

AbortError should be returned whenever a file operation is terminated before it has completed.

func (*AbortError) Error

func (e *AbortError) Error() string

Error implements standard go error interface.

func (*AbortError) Unwrap

func (e *AbortError) Unwrap() error

Unwrap returns an underlying error.

type ChunkPipe

type ChunkPipe struct {
	io.ReadCloser
	// contains filtered or unexported fields
}

ChunkPipe ensures that only the last read is smaller than the chunk size, regardless of size of individual writes.

func (*ChunkPipe) Close

func (c *ChunkPipe) Close() error

Close implements io.Closer

func (*ChunkPipe) Read

func (c *ChunkPipe) Read(b []byte) (int, error)

Read implements io.Reader

func (*ChunkPipe) Write

func (c *ChunkPipe) Write(b []byte) (int, error)

Writer implements io.Writer

type HashError

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

HashError should be returned whenever a file operation is terminated before it has completed.

func (*HashError) Error

func (e *HashError) Error() string

Error implements standard go error interface.

func (*HashError) Unwrap

func (e *HashError) Unwrap() error

Unwrap returns an underlying error.

type JoinSeeker added in v0.2.0

type JoinSeeker interface {
	Join(ctx context.Context, address swarm.Address) (dataOut io.ReadSeeker, dataLength int64, err error)
	Size(ctx context.Context, address swarm.Address) (dataLength int64, err error)
}

JoinSeeker provides a Joiner that can seek.

type Splitter

type Splitter interface {
	Split(ctx context.Context, dataIn io.ReadCloser, dataLength int64, toEncrypt bool) (addr swarm.Address, err error)
}

Splitter starts a new file splitting job.

Data is read from the provided reader. If the dataLength parameter is 0, data is read until io.EOF is encountered. When EOF is received and splitting is done, the resulting Swarm Address is returned.

Directories

Path Synopsis
Package pipeline provides functionality for hashing pipelines needed to create different flavors of merkelised representations of arbitrary data.
Package pipeline provides functionality for hashing pipelines needed to create different flavors of merkelised representations of arbitrary data.
Package joiner provides implementations of the file.Joiner interface
Package joiner provides implementations of the file.Joiner interface
Package splitter provides implementations of the file.Splitter interface
Package splitter provides implementations of the file.Splitter interface

Jump to

Keyboard shortcuts

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