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