Skip to content

Commit 7fe648c

Browse files
committed
refactor: replace InfoHash with external extracted crate
The `InfoHash` struct has been extracted into a new crate to be reused in other projects like the Torrust Index: https://github.com/torrust/bittorrent-primitives
1 parent 7d7dba5 commit 7fe648c

File tree

57 files changed

+85
-598
lines changed

Some content is hidden

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

57 files changed

+85
-598
lines changed

contrib/bencode/src/access/bencode.rs

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 3 deletions
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/src/info_hash.rs

Lines changed: 0 additions & 220 deletions
This file was deleted.

packages/primitives/src/lib.rs

Lines changed: 5 additions & 6 deletions
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/benches/helpers/asyn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use std::sync::Arc;
22
use std::time::{Duration, Instant};
33

4+
use bittorrent_primitives::info_hash::InfoHash;
45
use futures::stream::FuturesUnordered;
5-
use torrust_tracker_primitives::info_hash::InfoHash;
66
use torrust_tracker_torrent_repository::repository::RepositoryAsync;
77

88
use super::utils::{generate_unique_info_hashes, DEFAULT_PEER};

packages/torrent-repository/benches/helpers/sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use std::sync::Arc;
22
use std::time::{Duration, Instant};
33

4+
use bittorrent_primitives::info_hash::InfoHash;
45
use futures::stream::FuturesUnordered;
5-
use torrust_tracker_primitives::info_hash::InfoHash;
66
use torrust_tracker_torrent_repository::repository::Repository;
77

88
use super::utils::{generate_unique_info_hashes, DEFAULT_PEER};

packages/torrent-repository/benches/helpers/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::collections::HashSet;
22
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
33

44
use aquatic_udp_protocol::{AnnounceEvent, NumberOfBytes, PeerId};
5-
use torrust_tracker_primitives::info_hash::InfoHash;
5+
use bittorrent_primitives::info_hash::InfoHash;
66
use torrust_tracker_primitives::peer::Peer;
77
use torrust_tracker_primitives::DurationSinceUnixEpoch;
88
use zerocopy::I64;

packages/torrent-repository/src/repository/dash_map_mutex_std.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use std::sync::Arc;
22

3+
use bittorrent_primitives::info_hash::InfoHash;
34
use dashmap::DashMap;
45
use torrust_tracker_configuration::TrackerPolicy;
5-
use torrust_tracker_primitives::info_hash::InfoHash;
66
use torrust_tracker_primitives::pagination::Pagination;
77
use torrust_tracker_primitives::swarm_metadata::SwarmMetadata;
88
use torrust_tracker_primitives::torrent_metrics::TorrentsMetrics;

packages/torrent-repository/src/repository/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
use bittorrent_primitives::info_hash::InfoHash;
12
use torrust_tracker_configuration::TrackerPolicy;
2-
use torrust_tracker_primitives::info_hash::InfoHash;
33
use torrust_tracker_primitives::pagination::Pagination;
44
use torrust_tracker_primitives::swarm_metadata::SwarmMetadata;
55
use torrust_tracker_primitives::torrent_metrics::TorrentsMetrics;

packages/torrent-repository/src/repository/rw_lock_std.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
use bittorrent_primitives::info_hash::InfoHash;
12
use torrust_tracker_configuration::TrackerPolicy;
2-
use torrust_tracker_primitives::info_hash::InfoHash;
33
use torrust_tracker_primitives::pagination::Pagination;
44
use torrust_tracker_primitives::swarm_metadata::SwarmMetadata;
55
use torrust_tracker_primitives::torrent_metrics::TorrentsMetrics;
@@ -21,7 +21,7 @@ impl<T> RwLockStd<T> {
2121
/// Panics if unable to get a lock.
2222
pub fn write(
2323
&self,
24-
) -> std::sync::RwLockWriteGuard<'_, std::collections::BTreeMap<torrust_tracker_primitives::info_hash::InfoHash, T>> {
24+
) -> std::sync::RwLockWriteGuard<'_, std::collections::BTreeMap<bittorrent_primitives::info_hash::InfoHash, T>> {
2525
self.torrents.write().expect("it should get lock")
2626
}
2727
}

0 commit comments

Comments
 (0)