6 "github.com/anacrolix/torrent/metainfo"
9 type ClientImplCloser interface {
14 // Represents data storage for an unspecified torrent.
15 type ClientImpl interface {
16 OpenTorrent(info *metainfo.Info, infoHash metainfo.Hash) (TorrentImpl, error)
19 type TorrentCapacity *func() (cap int64, capped bool)
21 // Data storage bound to a torrent.
22 type TorrentImpl struct {
23 Piece func(p metainfo.Piece) PieceImpl
26 // Storages that share the same space, will provide equal pointers. The function is called once
27 // to determine the storage for torrents sharing the same function pointer, and mutated in
29 Capacity TorrentCapacity
32 // Interacts with torrent piece data. Optional interfaces to implement include:
33 // io.WriterTo, such as when a piece supports a more efficient way to write out incomplete chunks.
34 // SelfHashing, such as when a piece supports a more efficient way to hash its contents.
35 type PieceImpl interface {
36 // These interfaces are not as strict as normally required. They can
37 // assume that the parameters are appropriate for the dimensions of the
41 // Called when the client believes the piece data will pass a hash check.
42 // The storage can move or mark the piece data as read-only as it sees
45 MarkNotComplete() error
46 // Returns true if the piece is complete.
47 Completion() Completion
50 type Completion struct {
55 // Allows a storage backend to override hashing (i.e. if it can do it more efficiently than the torrent client can)
56 type SelfHashing interface {
57 SelfHash() (metainfo.Hash, error)