github.com/anacrolix/torrent@v1.61.0/storage/disabled/disabled.go (about)

     1  package disabled
     2  
     3  import (
     4  	"errors"
     5  
     6  	"github.com/anacrolix/torrent/metainfo"
     7  	"github.com/anacrolix/torrent/storage"
     8  )
     9  
    10  type Client struct{}
    11  
    12  func (c Client) OpenTorrent(info *metainfo.Info, infoHash metainfo.Hash) (storage.TorrentImpl, error) {
    13  	capFunc := func() (int64, bool) {
    14  		return 0, true
    15  	}
    16  	return storage.TorrentImpl{
    17  		Piece: func(piece metainfo.Piece) storage.PieceImpl {
    18  			return Piece{}
    19  		},
    20  		Close: func() error {
    21  			return nil
    22  		},
    23  		Capacity: &capFunc,
    24  	}, nil
    25  }
    26  
    27  type Piece struct{}
    28  
    29  func (Piece) ReadAt(p []byte, off int64) (n int, err error) {
    30  	err = errors.New("disabled")
    31  	return
    32  }
    33  
    34  func (Piece) WriteAt(p []byte, off int64) (n int, err error) {
    35  	err = errors.New("disabled")
    36  	return
    37  }
    38  
    39  func (Piece) MarkComplete() error {
    40  	return errors.New("disabled")
    41  }
    42  
    43  func (Piece) MarkNotComplete() error {
    44  	return errors.New("disabled")
    45  }
    46  
    47  func (Piece) Completion() storage.Completion {
    48  	return storage.Completion{
    49  		Complete: false,
    50  		Ok:       true,
    51  	}
    52  }