torrent/storage/interface.go

41 lines
949 B
Go
Raw Normal View History

2016-03-28 09:38:30 +00:00
package storage
2016-03-28 09:38:30 +00:00
import (
"io"
"github.com/anacrolix/torrent/metainfo"
)
// Represents data storage for an unspecified torrent.
type ClientImpl interface {
OpenTorrent(info *metainfo.Info, infoHash metainfo.Hash) (TorrentImpl, error)
Close() error
}
// Data storage bound to a torrent.
type TorrentImpl interface {
Piece(metainfo.Piece) PieceImpl
Close() error
2016-03-28 09:38:30 +00:00
}
// Interacts with torrent piece data.
type PieceImpl interface {
// These interfaces are not as strict as normally required. They can
2016-10-25 08:57:35 +00:00
// assume that the parameters are appropriate for the dimensions of the
// piece.
io.ReaderAt
io.WriterAt
2016-03-26 07:27:28 +00:00
// Called when the client believes the piece data will pass a hash check.
// The storage can move or mark the piece data as read-only as it sees
// fit.
2016-03-28 09:38:30 +00:00
MarkComplete() error
MarkNotComplete() error
// Returns true if the piece is complete.
Completion() Completion
}
type Completion struct {
Complete bool
Ok bool
}