Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BREAKING CHANGE] Implement remaining torrent-get fields #92

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ include = ["**/*.rs", "Cargo.toml"]

[features]
sync = []
tor-get-serde = []

[dependencies]
reqwest = { version = "0.12.5", features = [
Expand All @@ -25,6 +26,7 @@ enum-iterator = "2.1.0"
chrono = {version = "0.4.31", features = ["serde"] }

log = "0.4.20"
base64 = "0.22.1"

[dev-dependencies]
env_logger = "0.11.3"
Expand Down
9 changes: 6 additions & 3 deletions src/types/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
mod request;
mod response;

#[cfg(test)]
mod tests;

pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;

#[derive(Debug)]
Expand All @@ -16,7 +19,7 @@ pub use self::request::{
};

pub use self::response::{
BlocklistUpdate, ErrorType, FreeSpace, Nothing, PortTest, RpcResponse, RpcResponseArgument,
SessionClose, SessionGet, SessionSet, SessionStats, Torrent, TorrentAddedOrDuplicate,
TorrentRenamePath, TorrentStatus, Torrents,
BlocklistUpdate, ErrorType, FreeSpace, IdleMode, Nothing, PortTest, RatioMode, RpcResponse,
RpcResponseArgument, SessionClose, SessionGet, SessionSet, SessionStats, Torrent,
TorrentAddedOrDuplicate, TorrentRenamePath, TorrentStatus, Torrents, TrackerState,
};
73 changes: 72 additions & 1 deletion src/types/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,42 +471,77 @@ pub struct TorrentAddArgs {
pub labels: Option<Vec<String>>,
}

#[derive(Clone, Copy, Sequence)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Sequence)]
#[cfg_attr(feature = "tor-get-serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "tor-get-serde", serde(rename_all = "camelCase"))]
pub enum TorrentGetField {
ActivityDate,
AddedDate,
Availability,
BandwidthPriority,
Comment,
CorruptEver,
Creator,
DateCreated,
DesiredAvailable,
DoneDate,
DownloadDir,
DownloadedEver,
DownloadLimit,
DownloadLimited,
EditDate,
Error,
ErrorString,
Eta,
EtaIdle,
#[cfg_attr(feature = "tor-get-serde", serde(rename = "file-count"))]
FileCount,
FileStats,
Files,
Group,
HashString,
HaveUnchecked,
HaveValid,
HonorsSessionLimits,
Id,
IsFinished,
IsPrivate,
IsStalled,
Labels,
LeftUntilDone,
MagnetLink,
ManualAnnounceTime,
MaxConnectedPeers,
MetadataPercentComplete,
Name,
#[cfg_attr(feature = "tor-get-serde", serde(rename = "peer-limit"))]
PeerLimit,
Peers,
PeersConnected,
PeersFrom,
PeersGettingFromUs,
PeersSendingToUs,
PercentComplete,
PercentDone,
Pieces,
PieceCount,
PieceSize,
Priorities,
#[cfg_attr(feature = "tor-get-serde", serde(rename = "primary-mime-type"))]
PrimaryMimeType,
QueuePosition,
RateDownload,
RateUpload,
RecheckProgress,
SecondsDownloading,
SecondsSeeding,
SeedIdleLimit,
SeedIdleMode,
SeedRatioLimit,
SeedRatioMode,
SequentialDownload,
SizeWhenDone,
StartDate,
Status,
TorrentFile,
TotalSize,
Expand All @@ -515,7 +550,10 @@ pub enum TorrentGetField {
TrackerStats,
UploadRatio,
UploadedEver,
UploadLimit,
UploadLimited,
Wanted,
Webseeds,
WebseedsSendingToUs,
}

Expand All @@ -525,38 +563,68 @@ impl TorrentGetField {
match self {
TorrentGetField::ActivityDate => "activityDate",
TorrentGetField::AddedDate => "addedDate",
TorrentGetField::Availability => "availability",
TorrentGetField::BandwidthPriority => "bandwidthPriority",
TorrentGetField::Comment => "comment",
TorrentGetField::CorruptEver => "corruptEver",
TorrentGetField::Creator => "creator",
TorrentGetField::DateCreated => "dateCreated",
TorrentGetField::DesiredAvailable => "desiredAvailable",
TorrentGetField::DoneDate => "doneDate",
TorrentGetField::DownloadDir => "downloadDir",
TorrentGetField::DownloadedEver => "downloadedEver",
TorrentGetField::DownloadLimit => "downloadLimit",
TorrentGetField::DownloadLimited => "downloadLimited",
TorrentGetField::EditDate => "editDate",
TorrentGetField::Error => "error",
TorrentGetField::ErrorString => "errorString",
TorrentGetField::Eta => "eta",
TorrentGetField::EtaIdle => "etaIdle",
TorrentGetField::FileCount => "file-count",
TorrentGetField::FileStats => "fileStats",
TorrentGetField::Files => "files",
TorrentGetField::Group => "group",
TorrentGetField::HashString => "hashString",
TorrentGetField::HaveUnchecked => "haveUnchecked",
TorrentGetField::HaveValid => "haveValid",
TorrentGetField::HonorsSessionLimits => "honorsSessionLimits",
TorrentGetField::Id => "id",
TorrentGetField::IsFinished => "isFinished",
TorrentGetField::IsPrivate => "isPrivate",
TorrentGetField::IsStalled => "isStalled",
TorrentGetField::Labels => "labels",
TorrentGetField::LeftUntilDone => "leftUntilDone",
TorrentGetField::MagnetLink => "magnetLink",
TorrentGetField::ManualAnnounceTime => "manualAnnounceTime",
TorrentGetField::MaxConnectedPeers => "maxConnectedPeers",
TorrentGetField::MetadataPercentComplete => "metadataPercentComplete",
TorrentGetField::Name => "name",
TorrentGetField::PeerLimit => "peer-limit",
TorrentGetField::Peers => "peers",
TorrentGetField::PeersConnected => "peersConnected",
TorrentGetField::PeersFrom => "peersFrom",
TorrentGetField::PeersGettingFromUs => "peersGettingFromUs",
TorrentGetField::PeersSendingToUs => "peersSendingToUs",
TorrentGetField::PercentComplete => "percentComplete",
TorrentGetField::PercentDone => "percentDone",
TorrentGetField::Pieces => "pieces",
TorrentGetField::PieceCount => "pieceCount",
TorrentGetField::PieceSize => "pieceSize",
TorrentGetField::Priorities => "priorities",
TorrentGetField::PrimaryMimeType => "primary-mime-type",
TorrentGetField::QueuePosition => "queuePosition",
TorrentGetField::RateDownload => "rateDownload",
TorrentGetField::RateUpload => "rateUpload",
TorrentGetField::RecheckProgress => "recheckProgress",
TorrentGetField::SecondsDownloading => "secondsDownloading",
TorrentGetField::SecondsSeeding => "secondsSeeding",
TorrentGetField::SeedIdleLimit => "seedIdleLimit",
TorrentGetField::SeedIdleMode => "seedIdleMode",
TorrentGetField::SeedRatioLimit => "seedRatioLimit",
TorrentGetField::SeedRatioMode => "seedRatioMode",
TorrentGetField::SequentialDownload => "sequentialDownload",
TorrentGetField::SizeWhenDone => "sizeWhenDone",
TorrentGetField::StartDate => "startDate",
TorrentGetField::Status => "status",
TorrentGetField::TorrentFile => "torrentFile",
TorrentGetField::TotalSize => "totalSize",
Expand All @@ -565,7 +633,10 @@ impl TorrentGetField {
TorrentGetField::TrackerStats => "trackerStats",
TorrentGetField::UploadRatio => "uploadRatio",
TorrentGetField::UploadedEver => "uploadedEver",
TorrentGetField::UploadLimit => "uploadLimit",
TorrentGetField::UploadLimited => "uploadLimited",
TorrentGetField::Wanted => "wanted",
TorrentGetField::Webseeds => "webseeds",
TorrentGetField::WebseedsSendingToUs => "webseedsSendingToUs",
}
.to_string()
Expand Down
Loading
Loading