Skip to main content

Module torrent

Module torrent 

Source
Expand description

BitTorrent download support.

This module provides torrent downloading capabilities through multiple backends:

  • Native (torrent-native feature): Built-in BitTorrent client using librqbit
  • Transmission (torrent-transmission feature): 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 (requires torrent-native feature)
  • transmission: Use Transmission RPC (requires torrent-transmission feature)
  • Any other value: Open in system’s default torrent client

If not set, defaults to native when available, otherwise external.

Structs§

TorrentCallbacks
Callbacks for torrent download progress and status updates.

Functions§

download_magnet
Download a torrent from a magnet link.

Type Aliases§

ProgressCb
Type alias for progress callbacks (0.0 to 1.0).
StatusCb
Type alias for status message callbacks.