2023-12-03 12:14:50 +00:00
|
|
|
//!
|
|
|
|
|
//! This crate provides everything necessary to download [torrents](https://en.wikipedia.org/wiki/BitTorrent).
|
|
|
|
|
//!
|
|
|
|
|
//! # Quick usage example
|
|
|
|
|
//!
|
|
|
|
|
//! ```no_run
|
|
|
|
|
//! use librqbit::*;
|
|
|
|
|
//!
|
|
|
|
|
//! tokio_test::block_on(async {
|
|
|
|
|
//! let session = Session::new("/tmp/where-to-download".into()).await.unwrap();
|
|
|
|
|
//! let managed_torrent_handle = session.add_torrent(
|
|
|
|
|
//! AddTorrent::from_url("magnet:?xt=urn:btih:cab507494d02ebb1178b38f2e9d7be299c86b862"),
|
|
|
|
|
//! None // options
|
|
|
|
|
//! ).await.unwrap().into_handle().unwrap();
|
|
|
|
|
//! managed_torrent_handle.wait_until_completed().await.unwrap();
|
|
|
|
|
//! })
|
|
|
|
|
//! ```
|
|
|
|
|
//!
|
|
|
|
|
//! # Overview
|
|
|
|
|
//! The main type to start off with is [`Session`].
|
|
|
|
|
//!
|
|
|
|
|
//! It also proved useful to use the [`Api`] when building the rqbit desktop app, as it provides
|
|
|
|
|
//! a facade that works with simple serializable types.
|
2024-04-05 10:52:27 +01:00
|
|
|
//!
|
2023-12-03 12:14:50 +00:00
|
|
|
|
2024-04-24 14:19:04 +01:00
|
|
|
#![warn(clippy::cast_possible_truncation)]
|
|
|
|
|
|
2024-08-19 13:40:01 +01:00
|
|
|
macro_rules! aframe {
|
|
|
|
|
($e:expr) => {{
|
|
|
|
|
#[cfg(feature = "async-bt")]
|
|
|
|
|
{
|
|
|
|
|
async_backtrace::frame!($e)
|
|
|
|
|
}
|
|
|
|
|
#[cfg(not(feature = "async-bt"))]
|
|
|
|
|
{
|
|
|
|
|
$e
|
|
|
|
|
}
|
|
|
|
|
}};
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-02 15:19:05 +00:00
|
|
|
pub mod api;
|
2023-12-03 12:14:50 +00:00
|
|
|
mod api_error;
|
2024-08-20 15:07:23 +01:00
|
|
|
mod bitv;
|
2024-08-20 16:51:34 +01:00
|
|
|
mod bitv_factory;
|
2023-12-03 12:14:50 +00:00
|
|
|
mod chunk_tracker;
|
2024-03-05 09:18:22 +00:00
|
|
|
mod create_torrent_file;
|
2023-12-03 12:14:50 +00:00
|
|
|
mod dht_utils;
|
2024-04-29 21:44:21 +01:00
|
|
|
pub mod file_info;
|
2023-12-03 12:14:50 +00:00
|
|
|
mod file_ops;
|
2024-08-15 18:54:59 +01:00
|
|
|
#[cfg(feature = "http-api")]
|
2021-06-30 10:14:33 +01:00
|
|
|
pub mod http_api;
|
2024-08-15 18:54:59 +01:00
|
|
|
#[cfg(feature = "http-api")]
|
2021-10-22 08:03:04 +01:00
|
|
|
pub mod http_api_client;
|
2024-04-29 13:57:29 +01:00
|
|
|
mod merge_streams;
|
2023-12-03 12:14:50 +00:00
|
|
|
mod peer_connection;
|
|
|
|
|
mod peer_info_reader;
|
2023-12-29 20:33:37 -05:00
|
|
|
mod read_buf;
|
2023-12-03 12:14:50 +00:00
|
|
|
mod session;
|
2024-08-15 10:40:48 +01:00
|
|
|
mod session_persistence;
|
2024-08-21 13:22:22 +01:00
|
|
|
pub mod session_stats;
|
2023-12-03 12:14:50 +00:00
|
|
|
mod spawn_utils;
|
2024-04-30 09:28:39 +01:00
|
|
|
pub mod storage;
|
2024-08-08 00:35:32 +01:00
|
|
|
mod stream_connect;
|
2023-12-03 12:14:50 +00:00
|
|
|
mod torrent_state;
|
2024-08-15 18:54:59 +01:00
|
|
|
#[cfg(feature = "tracing-subscriber-utils")]
|
2023-12-09 00:26:14 +00:00
|
|
|
pub mod tracing_subscriber_config_utils;
|
2023-12-03 12:14:50 +00:00
|
|
|
mod type_aliases;
|
2024-08-21 23:57:21 +01:00
|
|
|
#[cfg(all(feature = "http-api", feature = "upnp-serve-adapter"))]
|
|
|
|
|
pub mod upnp_server_adapter;
|
2024-09-13 12:34:51 +01:00
|
|
|
#[cfg(feature = "watch")]
|
|
|
|
|
pub mod watch;
|
2023-12-03 12:14:50 +00:00
|
|
|
|
|
|
|
|
pub use api::Api;
|
|
|
|
|
pub use api_error::ApiError;
|
2024-03-05 09:18:22 +00:00
|
|
|
pub use create_torrent_file::{create_torrent, CreateTorrentOptions};
|
2023-12-03 12:14:50 +00:00
|
|
|
pub use dht;
|
|
|
|
|
pub use peer_connection::PeerConnectionOptions;
|
|
|
|
|
pub use session::{
|
|
|
|
|
AddTorrent, AddTorrentOptions, AddTorrentResponse, ListOnlyResponse, Session, SessionOptions,
|
2024-08-15 10:40:48 +01:00
|
|
|
SessionPersistenceConfig, SUPPORTED_SCHEMES,
|
2023-12-03 12:14:50 +00:00
|
|
|
};
|
|
|
|
|
pub use spawn_utils::spawn as librqbit_spawn;
|
2024-04-30 09:28:39 +01:00
|
|
|
pub use torrent_state::{
|
2024-08-21 16:12:20 +01:00
|
|
|
ManagedTorrent, ManagedTorrentShared, ManagedTorrentState, TorrentStats, TorrentStatsState,
|
2024-04-30 09:28:39 +01:00
|
|
|
};
|
2024-04-30 23:12:23 +01:00
|
|
|
pub use type_aliases::FileInfos;
|
2021-07-03 19:10:59 +01:00
|
|
|
|
|
|
|
|
pub use buffers::*;
|
|
|
|
|
pub use clone_to_owned::CloneToOwned;
|
|
|
|
|
pub use librqbit_core::magnet::*;
|
|
|
|
|
pub use librqbit_core::peer_id::*;
|
|
|
|
|
pub use librqbit_core::torrent_metainfo::*;
|
2023-12-06 12:14:26 +00:00
|
|
|
|
2024-03-05 09:18:22 +00:00
|
|
|
#[cfg(test)]
|
|
|
|
|
mod tests;
|
|
|
|
|
|
2023-12-06 12:14:26 +00:00
|
|
|
/// The cargo version of librqbit.
|
2024-08-29 13:08:55 +01:00
|
|
|
pub const fn version() -> &'static str {
|
2023-12-06 12:14:26 +00:00
|
|
|
env!("CARGO_PKG_VERSION")
|
|
|
|
|
}
|
2023-12-17 13:01:59 +00:00
|
|
|
|
2024-08-29 13:08:55 +01:00
|
|
|
pub const fn client_name_and_version() -> &'static str {
|
|
|
|
|
concat!("rqbit ", env!("CARGO_PKG_VERSION"))
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-17 13:01:59 +00:00
|
|
|
pub fn try_increase_nofile_limit() -> anyhow::Result<u64> {
|
|
|
|
|
Ok(rlimit::increase_nofile_limit(1024 * 1024)?)
|
|
|
|
|
}
|