mirror of
https://github.com/warppipe/swift-torrent.git
synced 2026-05-28 15:27:20 +00:00
6c8c581517
Full BEP-3 peer wire protocol, BEP-5 DHT, BEP-15 UDP trackers, magnet link support, bencode serialization, rarest-first piece selection, and async session management using SwiftNIO and swift-crypto. Includes 64 passing unit tests. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
30 lines
844 B
Swift
30 lines
844 B
Swift
import Foundation
|
|
|
|
/// Current state of a torrent.
|
|
public enum TorrentState: String, Sendable {
|
|
case checkingFiles = "checking_files"
|
|
case downloadingMetadata = "downloading_metadata"
|
|
case downloading
|
|
case seeding
|
|
case paused
|
|
case stopped
|
|
case error
|
|
}
|
|
|
|
/// A snapshot of a torrent's current status.
|
|
public struct TorrentStatus: Sendable {
|
|
public let infoHash: InfoHash
|
|
public let name: String
|
|
public let state: TorrentState
|
|
public let progress: Double // 0.0 to 1.0
|
|
public let downloadRate: Double // bytes per second
|
|
public let uploadRate: Double
|
|
public let totalDownloaded: Int64
|
|
public let totalUploaded: Int64
|
|
public let totalSize: Int64
|
|
public let numPeers: Int
|
|
public let numSeeds: Int
|
|
public let piecesCompleted: Int
|
|
public let piecesTotal: Int
|
|
}
|