package torrent import ( "context" "errors" ) var ( ErrNotConnected = errors.New("not connected") ErrAuthFailed = errors.New("authentication failed") ErrTorrentNotFound = errors.New("torrent not found") ErrInvalidRequest = errors.New("invalid request") ErrConnectionFailed = errors.New("connection failed") ) type TorrentState string const ( StateDownloading TorrentState = "downloading" StateSeeding TorrentState = "seeding" StatePaused TorrentState = "paused" StateQueued TorrentState = "queued" StateChecking TorrentState = "checking" StateError TorrentState = "error" StateUnknown TorrentState = "unknown" ) type TorrentInfo struct { Hash string `json:"hash"` Name string `json:"name"` Size uint64 `json:"size"` Progress float64 `json:"progress"` DownloadSpeed uint64 `json:"download_speed"` UploadSpeed uint64 `json:"upload_speed"` State TorrentState `json:"state"` SavePath string `json:"save_path"` } type Client interface { Connect(ctx context.Context) error Disconnect(ctx context.Context) error ListTorrents(ctx context.Context) ([]TorrentInfo, error) GetTorrent(ctx context.Context, hash string) (*TorrentInfo, error) AddTorrentURL(ctx context.Context, url string, savePath *string) error AddTorrentFile(ctx context.Context, data []byte, savePath *string) error RemoveTorrent(ctx context.Context, hash string, deleteFiles bool) error PauseTorrent(ctx context.Context, hash string) error ResumeTorrent(ctx context.Context, hash string) error }