Expand description
BitTorrent download support.
This module provides torrent downloading capabilities through multiple backends:
- Native (
torrent-nativefeature): Built-in BitTorrent client using librqbit - Transmission (
torrent-transmissionfeature): Transmission daemon RPC - External: Opens magnet links in the system’s default torrent client
§Native Torrent Client
The native client provides full BitTorrent protocol support:
- Magnet link parsing and metadata download
- DHT (Distributed Hash Table) for peer discovery
- Parallel piece downloading
- Progress callbacks for UI integration
§Example
use kget::torrent::{download_magnet, TorrentCallbacks};
use kget::{ProxyConfig, Optimizer};
use std::sync::Arc;
let callbacks = TorrentCallbacks {
status: Some(Arc::new(|msg| println!("{}", msg))),
progress: Some(Arc::new(|p| println!("{:.1}%", p * 100.0))),
};
download_magnet(
"magnet:?xt=urn:btih:...",
"./downloads",
false,
ProxyConfig::default(),
Optimizer::new(),
callbacks,
).expect("Torrent download failed");§Backend Selection
The backend is selected via the KGET_TORRENT_BACKEND environment variable:
native: Use built-in client (requirestorrent-nativefeature)transmission: Use Transmission RPC (requirestorrent-transmissionfeature)- Any other value: Open in system’s default torrent client
If not set, defaults to native when available, otherwise external.
Structs§
- Torrent
Callbacks - Callbacks for torrent download progress and status updates.
Functions§
- download_
magnet - Download a torrent from a magnet link.
Type Aliases§
- Progress
Cb - Type alias for progress callbacks (0.0 to 1.0).
- Status
Cb - Type alias for status message callbacks.