Skip to content

Commit ad10d1b

Browse files
committed
Merge torrust#1066: Refactor: extract duplicate implementation of InfoHash struct
7fe648c refactor: replace InfoHash with external extracted crate (Jose Celano) 7d7dba5 feat: add dep bittorrent-primitives (Jose Celano) Pull request description: Relates to: - torrust/torrust-index#251 - torrust/torrust-index#756 The `InfoHash` type was duplicated here and in the [Index](torrust/torrust-index#251). I've extracted it into a new crate. I'm planning to move the very basic types that we are using in other projects. I'm also planning to extract more packages like: - UDP tracker client - HTTP tracker client - Tracker console client (after merging UDP console client, HTTP console client and Tracker checker). See torrust#669 Some of those new packages also depend on this new [bittorrent-primitives](https://github.com/torrust/bittorrent-primitives) crate. ACKs for top commit: josecelano: ACK 7fe648c Tree-SHA512: 3ab5b2ef8631ae72b792dea6b1c9ab1e64b28f170d4580109872739427f0f50ae753af014d691e41bdffbf3a33da732cba89fd1487b9e219345e74b15599b1b7
2 parents 105dfc1 + 7fe648c commit ad10d1b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+112
-605
lines changed

Cargo.lock

+24-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ axum = { version = "0", features = ["macros"] }
3636
axum-client-ip = "0"
3737
axum-extra = { version = "0", features = ["query"] }
3838
axum-server = { version = "0", features = ["tls-rustls"] }
39+
bittorrent-primitives = "0.1.0"
3940
camino = { version = "1", features = ["serde", "serde1"] }
4041
chrono = { version = "0", default-features = false, features = ["clock"] }
4142
clap = { version = "4", features = ["derive", "env"] }

contrib/bencode/src/access/bencode.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub trait BRefAccessExt<'a>: BRefAccess {
5050
fn bytes_ext(&self) -> Option<&'a [u8]>;
5151
}
5252

53-
impl<'a, T> BRefAccess for &'a T
53+
impl<T> BRefAccess for &T
5454
where
5555
T: BRefAccess,
5656
{

packages/located-error/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ where
5050
location: Box<Location<'a>>,
5151
}
5252

53-
impl<'a, E> std::fmt::Display for LocatedError<'a, E>
53+
impl<E> std::fmt::Display for LocatedError<'_, E>
5454
where
5555
E: Error + ?Sized + Send + Sync,
5656
{
@@ -59,7 +59,7 @@ where
5959
}
6060
}
6161

62-
impl<'a, E> Error for LocatedError<'a, E>
62+
impl<E> Error for LocatedError<'_, E>
6363
where
6464
E: Error + ?Sized + Send + Sync + 'static,
6565
{
@@ -68,7 +68,7 @@ where
6868
}
6969
}
7070

71-
impl<'a, E> Clone for LocatedError<'a, E>
71+
impl<E> Clone for LocatedError<'_, E>
7272
where
7373
E: Error + ?Sized + Send + Sync,
7474
{

packages/primitives/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ version.workspace = true
1717
[dependencies]
1818
aquatic_udp_protocol = "0"
1919
binascii = "0"
20+
bittorrent-primitives = "0.1.0"
2021
derive_more = { version = "1", features = ["constructor"] }
2122
serde = { version = "1", features = ["derive"] }
2223
tdyne-peer-id = "1"

packages/primitives/src/info_hash.rs

-220
This file was deleted.

packages/primitives/src/lib.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,16 @@
44
//! which is a `BitTorrent` tracker server. These structures are used not only
55
//! by the tracker server crate, but also by other crates in the Torrust
66
//! ecosystem.
7-
use std::collections::BTreeMap;
8-
use std::time::Duration;
9-
10-
use info_hash::InfoHash;
11-
12-
pub mod info_hash;
137
pub mod pagination;
148
pub mod peer;
159
pub mod swarm_metadata;
1610
pub mod torrent_metrics;
1711

12+
use std::collections::BTreeMap;
13+
use std::time::Duration;
14+
15+
use bittorrent_primitives::info_hash::InfoHash;
16+
1817
/// Duration since the Unix Epoch.
1918
pub type DurationSinceUnixEpoch = Duration;
2019

packages/torrent-repository/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ version.workspace = true
1717

1818
[dependencies]
1919
aquatic_udp_protocol = "0"
20+
bittorrent-primitives = "0.1.0"
2021
crossbeam-skiplist = "0"
2122
dashmap = "6"
2223
futures = "0"

0 commit comments

Comments
 (0)