Expand description
High-level BitTorrent library.
This crate provides the user-facing API for building BitTorrent clients.
It depends on torrent_core for all low-level data types and adds
async I/O via tokio for networking, file storage, and session management.
§Re-exports
Commonly used core types are re-exported for convenience:
§Quick Start
use std::path::PathBuf;
use torrent::session::{Session, SessionConfig};
let config = SessionConfig {
download_dir: PathBuf::from("./downloads"),
..Default::default()
};
let session = Session::new(config).await.unwrap();
let data = std::fs::read("torrent.torrent").unwrap();
let info_hash = session.add_torrent_bytes(&data).await.unwrap();Modules§
- bencode
- Bencode encoding and decoding (BEP 3).
- dht
- DHT networking — async RPC and query helpers.
- error
- Error types for the torrent library.
- magnet
- Magnet URI parsing (BEP 9).
- metainfo
- .torrent file parsing and metadata (BEP 3, 12, 52).
- peer
- Async peer communication.
- piece
- Piece management and selection for the BitTorrent protocol.
- session
- High-level session management — orchestrates all BitTorrent modules.
- spec
- Torrent specification — either full metadata or a magnet link.
- storage
- Async file-based storage.
- tracker
- Async tracker implementations — HTTP (plain + TLS) and UDP announce.
Structs§
- PeerId
- A 20-byte peer identifier (BEP 3).