2
0
mirror of synced 2025-02-24 06:38:14 +00:00
torrent/storage/interface.go
Matt Joiner a5b54f21a1 Make opening a torrent in storage an explicit method
This is storage types where opening can fail, like mmap
2016-03-28 22:40:29 +11:00

33 lines
767 B
Go

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