qbt-clean 0.122.0

Automated rules-based cleaning of qBittorrent torrents.
#[derive(Default)]
pub struct QbtMock {
	pub trackers: Vec<crate::Tracker>,
}

impl QbtMock {
	pub fn with_trackers(
		trackers: impl IntoIterator<Item = crate::Tracker>,
	) -> Self {
		Self { trackers: trackers.into_iter().collect() }
	}
}

pub fn global_with_trackers(
	config: crate::Config,
	now: std::time::SystemTime,
	trackers: impl IntoIterator<Item = crate::Tracker>,
) -> crate::Global<QbtMock> {
	crate::Global {
		config,
		now,
		qbt: QbtMock::with_trackers(trackers),
	}
}

impl crate::Qbt for QbtMock {
	async fn logout(self) -> anyhow::Result<()> {
		unimplemented!("QbtMock::logout")
	}

	async fn server_state(&self) -> anyhow::Result<crate::ServerState> {
		unimplemented!("QbtMock::server_state")
	}

	async fn torrents_info(&self) -> anyhow::Result<Vec<crate::Torrent>> {
		unimplemented!("QbtMock::torrents_info")
	}

	async fn torrent_files(&self, _: crate::InfoHash)
		-> anyhow::Result<Vec<crate::TorrentFile>>
	{
		unimplemented!("QbtMock::torrent_files")
	}

	async fn torrent_trackers(&self, _: crate::InfoHash)
		-> anyhow::Result<Vec<crate::Tracker>>
	{
		Ok(self.trackers.iter().map(|t| crate::Tracker {
			msg: t.msg.clone(),
			url: t.url.clone(),
		}).collect())
	}

	async fn delete_torrents(&self, _: &[crate::InfoHash]) -> anyhow::Result<()> {
		unimplemented!("QbtMock::delete_torrents")
	}
}