github.com/ethersphere/bee/v2@v2.2.0/pkg/file/file.go (about)

     1  // Copyright 2020 The Swarm Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Package file provides interfaces for file-oriented operations.
     6  package file
     7  
     8  import (
     9  	"context"
    10  	"io"
    11  
    12  	"github.com/ethersphere/bee/v2/pkg/swarm"
    13  )
    14  
    15  type Reader interface {
    16  	io.ReadSeeker
    17  	io.ReaderAt
    18  }
    19  
    20  // Joiner provides the inverse functionality of the Splitter.
    21  type Joiner interface {
    22  	Reader
    23  	// IterateChunkAddresses is used to iterate over chunks addresses of some root hash.
    24  	IterateChunkAddresses(swarm.AddressIterFunc) error
    25  	// Size returns the span of the hash trie represented by the joiner's root hash.
    26  	Size() int64
    27  }
    28  
    29  // Splitter starts a new file splitting job.
    30  //
    31  // Data is read from the provided reader.
    32  // If the dataLength parameter is 0, data is read until io.EOF is encountered.
    33  // When EOF is received and splitting is done, the resulting Swarm Address is returned.
    34  type Splitter interface {
    35  	Split(ctx context.Context, dataIn io.ReadCloser, dataLength int64, toEncrypt bool) (addr swarm.Address, err error)
    36  }