diff --git a/Cargo.lock b/Cargo.lock index f55c673..0a8b71d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2398,7 +2398,6 @@ name = "librqbit-core" version = "4.0.1" dependencies = [ "anyhow", - "assert_cfg", "bytes", "data-encoding", "directories", diff --git a/crates/bencode/Cargo.toml b/crates/bencode/Cargo.toml index d518cde..ae054bb 100644 --- a/crates/bencode/Cargo.toml +++ b/crates/bencode/Cargo.toml @@ -19,5 +19,5 @@ serde = { version = "1", features = ["derive"] } buffers = { path = "../buffers", package = "librqbit-buffers", version = "4" } clone_to_owned = { path = "../clone_to_owned", package = "librqbit-clone-to-owned", version = "3" } anyhow = "1" -sha1w = { path = "../sha1w", default-features = false, package = "librqbit-sha1-wrapper", version = "4" } +sha1w = { path = "../sha1w", default-features = false, optional = true, package = "librqbit-sha1-wrapper", version = "4" } bytes = "1.7.1" diff --git a/crates/librqbit_core/Cargo.toml b/crates/librqbit_core/Cargo.toml index 403b0ce..b6c7850 100644 --- a/crates/librqbit_core/Cargo.toml +++ b/crates/librqbit_core/Cargo.toml @@ -31,8 +31,6 @@ directories = "5" tokio-util = "0.7.10" data-encoding = "2.6.0" bytes = "1.7.1" -assert_cfg = "0.1.0" - [dev-dependencies] serde_json = "1" diff --git a/crates/librqbit_core/src/lengths.rs b/crates/librqbit_core/src/lengths.rs index 1f06053..dd973ae 100644 --- a/crates/librqbit_core/src/lengths.rs +++ b/crates/librqbit_core/src/lengths.rs @@ -1,6 +1,6 @@ use anyhow::Context; -use crate::{constants::CHUNK_SIZE, torrent_metainfo::TorrentMetaV1Info}; +use crate::constants::CHUNK_SIZE; pub fn last_element_size(total_length: T, piece_length: T) -> T where @@ -73,8 +73,9 @@ impl ValidPieceIndex { } impl Lengths { + #[cfg(any(feature = "sha1-crypto-hash", feature = "sha1-ring"))] pub fn from_torrent>( - torrent: &TorrentMetaV1Info, + torrent: &crate::torrent_metainfo::TorrentMetaV1Info, ) -> anyhow::Result { let total_length = torrent.iter_file_lengths()?.sum(); Lengths::new(total_length, torrent.piece_length) @@ -157,11 +158,7 @@ impl Lengths { } // A helper to iterate over pieces in a file. - pub(crate) fn iter_pieces_within_offset( - &self, - offset_bytes: u64, - len: u64, - ) -> std::ops::Range { + pub fn iter_pieces_within_offset(&self, offset_bytes: u64, len: u64) -> std::ops::Range { // Validation and correction let offset_bytes = offset_bytes.min(self.total_length); let end_bytes = (offset_bytes + len).min(self.total_length); diff --git a/crates/librqbit_core/src/lib.rs b/crates/librqbit_core/src/lib.rs index eb6d654..636d6b7 100644 --- a/crates/librqbit_core/src/lib.rs +++ b/crates/librqbit_core/src/lib.rs @@ -1,16 +1,13 @@ pub mod constants; pub mod directories; pub mod hash_id; + pub mod lengths; pub mod magnet; pub mod peer_id; pub mod spawn_utils; pub mod speed_estimator; +#[cfg(any(feature = "sha1-crypto-hash", feature = "sha1-ring"))] pub mod torrent_metainfo; pub use hash_id::Id20; - -assert_cfg::exactly_one! { - feature = "sha1-crypto-hash", - feature = "sha1-ring", -}