]> Sergey Matveev's repositories - btrtrc.git/blob - storage/interface.go
New storage interface
[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 }