]> Sergey Matveev's repositories - btrtrc.git/blob - storage/interface.go
Differentiate between storage.ClientImpl{,Closer}
[btrtrc.git] / storage / interface.go
1 package storage
2
3 import (
4         "io"
5
6         "github.com/anacrolix/torrent/metainfo"
7 )
8
9 type ClientImplCloser interface {
10         ClientImpl
11         Close() error
12 }
13
14 // Represents data storage for an unspecified torrent.
15 type ClientImpl interface {
16         OpenTorrent(info *metainfo.Info, infoHash metainfo.Hash) (TorrentImpl, error)
17 }
18
19 // Data storage bound to a torrent.
20 type TorrentImpl interface {
21         Piece(metainfo.Piece) PieceImpl
22         Close() error
23 }
24
25 // Interacts with torrent piece data.
26 type PieceImpl interface {
27         // These interfaces are not as strict as normally required. They can
28         // assume that the parameters are appropriate for the dimensions of the
29         // piece.
30         io.ReaderAt
31         io.WriterAt
32         // Called when the client believes the piece data will pass a hash check.
33         // The storage can move or mark the piece data as read-only as it sees
34         // fit.
35         MarkComplete() error
36         MarkNotComplete() error
37         // Returns true if the piece is complete.
38         Completion() Completion
39 }
40
41 type Completion struct {
42         Complete bool
43         Ok       bool
44 }