77use std:: collections:: BTreeMap ;
88use std:: time:: Duration ;
99
10- use aquatic_udp_protocol:: { AnnounceEvent , NumberOfBytes } ;
1110use info_hash:: InfoHash ;
12- use serde:: Serialize ;
1311
1412pub mod info_hash;
1513pub mod pagination;
@@ -20,48 +18,6 @@ pub mod torrent_metrics;
2018/// Duration since the Unix Epoch.
2119pub type DurationSinceUnixEpoch = Duration ;
2220
23- /// Serializes a `DurationSinceUnixEpoch` as a Unix timestamp in milliseconds.
24- /// # Errors
25- ///
26- /// Will return `serde::Serializer::Error` if unable to serialize the `unix_time_value`.
27- pub fn ser_unix_time_value < S : serde:: Serializer > ( unix_time_value : & DurationSinceUnixEpoch , ser : S ) -> Result < S :: Ok , S :: Error > {
28- #[ allow( clippy:: cast_possible_truncation) ]
29- ser. serialize_u64 ( unix_time_value. as_millis ( ) as u64 )
30- }
31-
32- #[ derive( Serialize ) ]
33- pub enum AnnounceEventSer {
34- Started ,
35- Stopped ,
36- Completed ,
37- None ,
38- }
39-
40- /// Serializes a `Announce Event` as a enum.
41- ///
42- /// # Errors
43- ///
44- /// If will return an error if the internal serializer was to fail.
45- pub fn ser_announce_event < S : serde:: Serializer > ( announce_event : & AnnounceEvent , ser : S ) -> Result < S :: Ok , S :: Error > {
46- let event_ser = match announce_event {
47- AnnounceEvent :: Started => AnnounceEventSer :: Started ,
48- AnnounceEvent :: Stopped => AnnounceEventSer :: Stopped ,
49- AnnounceEvent :: Completed => AnnounceEventSer :: Completed ,
50- AnnounceEvent :: None => AnnounceEventSer :: None ,
51- } ;
52-
53- ser. serialize_some ( & event_ser)
54- }
55-
56- /// Serializes a `Announce Event` as a i64.
57- ///
58- /// # Errors
59- ///
60- /// If will return an error if the internal serializer was to fail.
61- pub fn ser_number_of_bytes < S : serde:: Serializer > ( number_of_bytes : & NumberOfBytes , ser : S ) -> Result < S :: Ok , S :: Error > {
62- ser. serialize_i64 ( number_of_bytes. 0 . get ( ) )
63- }
64-
6521/// IP version used by the peer to connect to the tracker: IPv4 or IPv6
6622#[ derive( PartialEq , Eq , Debug ) ]
6723pub enum IPVersion {
0 commit comments