Skip to content

Commit

Permalink
Merge #1066: Refactor: extract duplicate implementation of InfoHash
Browse files Browse the repository at this point in the history
… 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 #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
  • Loading branch information
josecelano committed Oct 31, 2024
2 parents 105dfc1 + 7fe648c commit ad10d1b
Show file tree
Hide file tree
Showing 61 changed files with 112 additions and 605 deletions.
31 changes: 24 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ axum = { version = "0", features = ["macros"] }
axum-client-ip = "0"
axum-extra = { version = "0", features = ["query"] }
axum-server = { version = "0", features = ["tls-rustls"] }
bittorrent-primitives = "0.1.0"
camino = { version = "1", features = ["serde", "serde1"] }
chrono = { version = "0", default-features = false, features = ["clock"] }
clap = { version = "4", features = ["derive", "env"] }
Expand Down
2 changes: 1 addition & 1 deletion contrib/bencode/src/access/bencode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub trait BRefAccessExt<'a>: BRefAccess {
fn bytes_ext(&self) -> Option<&'a [u8]>;
}

impl<'a, T> BRefAccess for &'a T
impl<T> BRefAccess for &T
where
T: BRefAccess,
{
Expand Down
6 changes: 3 additions & 3 deletions packages/located-error/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ where
location: Box<Location<'a>>,
}

impl<'a, E> std::fmt::Display for LocatedError<'a, E>
impl<E> std::fmt::Display for LocatedError<'_, E>
where
E: Error + ?Sized + Send + Sync,
{
Expand All @@ -59,7 +59,7 @@ where
}
}

impl<'a, E> Error for LocatedError<'a, E>
impl<E> Error for LocatedError<'_, E>
where
E: Error + ?Sized + Send + Sync + 'static,
{
Expand All @@ -68,7 +68,7 @@ where
}
}

impl<'a, E> Clone for LocatedError<'a, E>
impl<E> Clone for LocatedError<'_, E>
where
E: Error + ?Sized + Send + Sync,
{
Expand Down
1 change: 1 addition & 0 deletions packages/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ version.workspace = true
[dependencies]
aquatic_udp_protocol = "0"
binascii = "0"
bittorrent-primitives = "0.1.0"
derive_more = { version = "1", features = ["constructor"] }
serde = { version = "1", features = ["derive"] }
tdyne-peer-id = "1"
Expand Down
220 changes: 0 additions & 220 deletions packages/primitives/src/info_hash.rs

This file was deleted.

11 changes: 5 additions & 6 deletions packages/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@
//! which is a `BitTorrent` tracker server. These structures are used not only
//! by the tracker server crate, but also by other crates in the Torrust
//! ecosystem.
use std::collections::BTreeMap;
use std::time::Duration;

use info_hash::InfoHash;

pub mod info_hash;
pub mod pagination;
pub mod peer;
pub mod swarm_metadata;
pub mod torrent_metrics;

use std::collections::BTreeMap;
use std::time::Duration;

use bittorrent_primitives::info_hash::InfoHash;

/// Duration since the Unix Epoch.
pub type DurationSinceUnixEpoch = Duration;

Expand Down
1 change: 1 addition & 0 deletions packages/torrent-repository/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ version.workspace = true

[dependencies]
aquatic_udp_protocol = "0"
bittorrent-primitives = "0.1.0"
crossbeam-skiplist = "0"
dashmap = "6"
futures = "0"
Expand Down
Loading

0 comments on commit ad10d1b

Please sign in to comment.