]> Sergey Matveev's repositories - btrtrc.git/blob - storage/interface.go
Rename storage.I->Client
[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 Client interface {
11         OpenTorrent(info *metainfo.InfoEx) (Torrent, error)
12 }
13
14 // Data storage bound to a torrent.
15 type Torrent interface {
16         Piece(metainfo.Piece) Piece
17         Close() error
18 }
19
20 // Interacts with torrent piece data.
21 type Piece interface {
22         // Should return io.EOF only at end of torrent. Short reads due to missing
23         // data should return io.ErrUnexpectedEOF.
24         io.ReaderAt
25         io.WriterAt
26         // Called when the client believes the piece data will pass a hash check.
27         // The storage can move or mark the piece data as read-only as it sees
28         // fit.
29         MarkComplete() error
30         // Returns true if the piece is complete.
31         GetIsComplete() bool
32 }