gosh_dl/
lib.rs

1//! # gosh-dl
2//!
3//! A fast, safe, and reliable download engine written in Rust.
4//!
5//! ## Features
6//!
7//! - **HTTP/HTTPS Downloads**: Multi-connection segmented downloads with resume support
8//! - **BitTorrent**: Full protocol support including DHT, PEX, and LPD
9//! - **Cross-platform**: Works on Linux, macOS, and Windows
10//! - **Memory-safe**: Written in Rust with no unsafe code in core paths
11//! - **Async**: Built on Tokio for efficient concurrent downloads
12//!
13//! ## Quick Start
14//!
15//! ```rust,no_run
16//! use gosh_dl::{DownloadEngine, EngineConfig, DownloadOptions};
17//!
18//! #[tokio::main]
19//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
20//!     // Create engine with default config
21//!     let config = EngineConfig::default();
22//!     let engine = DownloadEngine::new(config).await?;
23//!
24//!     // Add a download
25//!     let id = engine.add_http(
26//!         "https://example.com/file.zip",
27//!         DownloadOptions::default(),
28//!     ).await?;
29//!
30//!     // Subscribe to events
31//!     let mut events = engine.subscribe();
32//!     while let Ok(event) = events.recv().await {
33//!         println!("Event: {:?}", event);
34//!     }
35//!
36//!     Ok(())
37//! }
38//! ```
39
40// Modules
41pub mod config;
42pub mod engine;
43pub mod error;
44pub mod http;
45pub mod priority_queue;
46pub mod protocol;
47pub mod scheduler;
48pub mod storage;
49pub mod torrent;
50pub mod types;
51
52// Re-exports for convenience
53pub use config::{AllocationMode, EngineConfig, HttpConfig, TorrentConfig};
54pub use engine::DownloadEngine;
55pub use error::{EngineError, NetworkErrorKind, ProtocolErrorKind, Result, StorageErrorKind};
56pub use protocol::{ProtocolError, ProtocolResult};
57pub use types::{
58    DownloadEvent, DownloadId, DownloadKind, DownloadMetadata, DownloadOptions, DownloadProgress,
59    DownloadState, DownloadStatus, GlobalStats, PeerInfo, TorrentFile, TorrentInfo,
60    TorrentStatusInfo,
61};
62
63// Storage exports
64pub use storage::{MemoryStorage, Segment, SegmentState, SqliteStorage, Storage};
65
66// Priority queue exports
67pub use priority_queue::{DownloadPriority, PriorityQueue, PriorityQueueStats};
68
69// Scheduler exports
70pub use scheduler::{BandwidthLimits, BandwidthScheduler, ScheduleRule};
71
72// HTTP module exports
73pub use http::{
74    ConnectionPool, HttpDownloader, ResumeInfo, RetryPolicy, SegmentedDownload, ServerCapabilities,
75    SpeedCalculator,
76};