2
0
mirror of synced 2025-02-24 14:48:27 +00:00
torrent/storage/interface.go

33 lines
767 B
Go
Raw Normal View History

2016-03-28 20:38:30 +11:00
package storage
2016-03-28 20:38:30 +11:00
import (
"io"
"github.com/anacrolix/torrent/metainfo"
)
// Represents data storage for an unspecified torrent.
2016-03-28 20:38:30 +11:00
type I interface {
OpenTorrent(info *metainfo.InfoEx) (Torrent, error)
}
// Data storage bound to a torrent.
type Torrent interface {
2016-03-28 20:38:30 +11:00
Piece(metainfo.Piece) Piece
Close() error
2016-03-28 20:38:30 +11:00
}
// Interacts with torrent piece data.
2016-03-28 20:38:30 +11:00
type Piece interface {
2016-03-26 18:27:28 +11:00
// Should return io.EOF only at end of torrent. Short reads due to missing
// data should return io.ErrUnexpectedEOF.
io.ReaderAt
io.WriterAt
2016-03-26 18:27:28 +11: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 20:38:30 +11:00
MarkComplete() error
// Returns true if the piece is complete.
2016-03-28 20:38:30 +11:00
GetIsComplete() bool
}