@@ -23,56 +23,6 @@ use torrust_tracker_primitives::core::AnnounceData;
2323
2424use crate :: statistics;
2525
26- /// Errors related to announce requests.
27- #[ derive( thiserror:: Error , Debug , Clone ) ]
28- pub enum HttpAnnounceError {
29- #[ error( "Error resolving peer IP: {source}" ) ]
30- PeerIpResolutionError { source : PeerIpResolutionError } ,
31-
32- #[ error( "Tracker core error: {source}" ) ]
33- TrackerCoreError { source : TrackerCoreError } ,
34- }
35-
36- impl From < PeerIpResolutionError > for HttpAnnounceError {
37- fn from ( peer_ip_resolution_error : PeerIpResolutionError ) -> Self {
38- Self :: PeerIpResolutionError {
39- source : peer_ip_resolution_error,
40- }
41- }
42- }
43-
44- impl From < TrackerCoreError > for HttpAnnounceError {
45- fn from ( tracker_core_error : TrackerCoreError ) -> Self {
46- Self :: TrackerCoreError {
47- source : tracker_core_error,
48- }
49- }
50- }
51-
52- impl From < AnnounceError > for HttpAnnounceError {
53- fn from ( announce_error : AnnounceError ) -> Self {
54- Self :: TrackerCoreError {
55- source : announce_error. into ( ) ,
56- }
57- }
58- }
59-
60- impl From < WhitelistError > for HttpAnnounceError {
61- fn from ( whitelist_error : WhitelistError ) -> Self {
62- Self :: TrackerCoreError {
63- source : whitelist_error. into ( ) ,
64- }
65- }
66- }
67-
68- impl From < authentication:: key:: Error > for HttpAnnounceError {
69- fn from ( whitelist_error : authentication:: key:: Error ) -> Self {
70- Self :: TrackerCoreError {
71- source : whitelist_error. into ( ) ,
72- }
73- }
74- }
75-
7626/// The HTTP tracker `announce` service.
7727///
7828/// The service sends an statistics event that increments:
@@ -184,6 +134,56 @@ impl AnnounceService {
184134 }
185135}
186136
137+ /// Errors related to announce requests.
138+ #[ derive( thiserror:: Error , Debug , Clone ) ]
139+ pub enum HttpAnnounceError {
140+ #[ error( "Error resolving peer IP: {source}" ) ]
141+ PeerIpResolutionError { source : PeerIpResolutionError } ,
142+
143+ #[ error( "Tracker core error: {source}" ) ]
144+ TrackerCoreError { source : TrackerCoreError } ,
145+ }
146+
147+ impl From < PeerIpResolutionError > for HttpAnnounceError {
148+ fn from ( peer_ip_resolution_error : PeerIpResolutionError ) -> Self {
149+ Self :: PeerIpResolutionError {
150+ source : peer_ip_resolution_error,
151+ }
152+ }
153+ }
154+
155+ impl From < TrackerCoreError > for HttpAnnounceError {
156+ fn from ( tracker_core_error : TrackerCoreError ) -> Self {
157+ Self :: TrackerCoreError {
158+ source : tracker_core_error,
159+ }
160+ }
161+ }
162+
163+ impl From < AnnounceError > for HttpAnnounceError {
164+ fn from ( announce_error : AnnounceError ) -> Self {
165+ Self :: TrackerCoreError {
166+ source : announce_error. into ( ) ,
167+ }
168+ }
169+ }
170+
171+ impl From < WhitelistError > for HttpAnnounceError {
172+ fn from ( whitelist_error : WhitelistError ) -> Self {
173+ Self :: TrackerCoreError {
174+ source : whitelist_error. into ( ) ,
175+ }
176+ }
177+ }
178+
179+ impl From < authentication:: key:: Error > for HttpAnnounceError {
180+ fn from ( whitelist_error : authentication:: key:: Error ) -> Self {
181+ Self :: TrackerCoreError {
182+ source : whitelist_error. into ( ) ,
183+ }
184+ }
185+ }
186+
187187#[ cfg( test) ]
188188mod tests {
189189 use std:: net:: { IpAddr , Ipv4Addr , Ipv6Addr , SocketAddr } ;
0 commit comments