Skip to content

Commit 3c4dcdb

Browse files
committed
refactor: rearrange code
1 parent 9326da3 commit 3c4dcdb

File tree

1 file changed

+36
-36
lines changed
  • packages/udp-tracker-core/src/services

1 file changed

+36
-36
lines changed

packages/udp-tracker-core/src/services/scrape.rs

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,42 +20,6 @@ use torrust_tracker_primitives::core::ScrapeData;
2020
use crate::connection_cookie::{check, gen_remote_fingerprint, ConnectionCookieError};
2121
use crate::statistics;
2222

23-
/// Errors related to scrape requests.
24-
#[derive(thiserror::Error, Debug, Clone)]
25-
pub enum UdpScrapeError {
26-
/// Error returned when there was an error with the connection cookie.
27-
#[error("Connection cookie error: {source}")]
28-
ConnectionCookieError { source: ConnectionCookieError },
29-
30-
/// Error returned when there was an error with the tracker core scrape handler.
31-
#[error("Tracker core scrape error: {source}")]
32-
TrackerCoreScrapeError { source: ScrapeError },
33-
34-
/// Error returned when there was an error with the tracker core whitelist.
35-
#[error("Tracker core whitelist error: {source}")]
36-
TrackerCoreWhitelistError { source: WhitelistError },
37-
}
38-
39-
impl From<ConnectionCookieError> for UdpScrapeError {
40-
fn from(connection_cookie_error: ConnectionCookieError) -> Self {
41-
Self::ConnectionCookieError {
42-
source: connection_cookie_error,
43-
}
44-
}
45-
}
46-
47-
impl From<ScrapeError> for UdpScrapeError {
48-
fn from(scrape_error: ScrapeError) -> Self {
49-
Self::TrackerCoreScrapeError { source: scrape_error }
50-
}
51-
}
52-
53-
impl From<WhitelistError> for UdpScrapeError {
54-
fn from(whitelist_error: WhitelistError) -> Self {
55-
Self::TrackerCoreWhitelistError { source: whitelist_error }
56-
}
57-
}
58-
5923
/// The `ScrapeService` is responsible for handling the `scrape` requests.
6024
pub struct ScrapeService {
6125
scrape_handler: Arc<ScrapeHandler>,
@@ -111,3 +75,39 @@ impl ScrapeService {
11175
Ok(scrape_data)
11276
}
11377
}
78+
79+
/// Errors related to scrape requests.
80+
#[derive(thiserror::Error, Debug, Clone)]
81+
pub enum UdpScrapeError {
82+
/// Error returned when there was an error with the connection cookie.
83+
#[error("Connection cookie error: {source}")]
84+
ConnectionCookieError { source: ConnectionCookieError },
85+
86+
/// Error returned when there was an error with the tracker core scrape handler.
87+
#[error("Tracker core scrape error: {source}")]
88+
TrackerCoreScrapeError { source: ScrapeError },
89+
90+
/// Error returned when there was an error with the tracker core whitelist.
91+
#[error("Tracker core whitelist error: {source}")]
92+
TrackerCoreWhitelistError { source: WhitelistError },
93+
}
94+
95+
impl From<ConnectionCookieError> for UdpScrapeError {
96+
fn from(connection_cookie_error: ConnectionCookieError) -> Self {
97+
Self::ConnectionCookieError {
98+
source: connection_cookie_error,
99+
}
100+
}
101+
}
102+
103+
impl From<ScrapeError> for UdpScrapeError {
104+
fn from(scrape_error: ScrapeError) -> Self {
105+
Self::TrackerCoreScrapeError { source: scrape_error }
106+
}
107+
}
108+
109+
impl From<WhitelistError> for UdpScrapeError {
110+
fn from(whitelist_error: WhitelistError) -> Self {
111+
Self::TrackerCoreWhitelistError { source: whitelist_error }
112+
}
113+
}

0 commit comments

Comments
 (0)