]> Sergey Matveev's repositories - btrtrc.git/blob - storage/interface.go
Get mmap storage working
[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 a Torrent.
10 type I interface {
11         Piece(metainfo.Piece) Piece
12 }
13
14 type Piece interface {
15         // Should return io.EOF only at end of torrent. Short reads due to missing
16         // data should return io.ErrUnexpectedEOF.
17         io.ReaderAt
18         io.WriterAt
19         // Called when the client believes the piece data will pass a hash check.
20         // The storage can move or mark the piece data as read-only as it sees
21         // fit.
22         MarkComplete() error
23         // Returns true if the piece is complete.
24         GetIsComplete() bool
25 }
26
27 // type PieceStorage interface {
28 //      ReadAt(metainfo.Piece, []byte, int64) (int, error)
29 //      WriteAt(metainfo.Piece, []byte, int64) (int, error)
30 //      MarkComplete(metainfo.Piece) error
31 //      GetIsComplete(metainfo.Piece) bool
32 // }
33
34 // type wrappedPieceStorage struct {
35 //      ps PieceStorage
36 // }
37
38 // func WrapPieceStorage(ps PieceStorage) I {
39 //      return wrappedPieceStorage{ps}
40 // }
41
42 // func (me wrappedPieceStorage) Piece(metainfo.Piece)