7
7
use std:: collections:: BTreeMap ;
8
8
use std:: time:: Duration ;
9
9
10
- use aquatic_udp_protocol:: { AnnounceEvent , NumberOfBytes } ;
11
10
use info_hash:: InfoHash ;
12
- use serde:: Serialize ;
13
11
14
12
pub mod info_hash;
15
13
pub mod pagination;
@@ -20,48 +18,6 @@ pub mod torrent_metrics;
20
18
/// Duration since the Unix Epoch.
21
19
pub type DurationSinceUnixEpoch = Duration ;
22
20
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
-
65
21
/// IP version used by the peer to connect to the tracker: IPv4 or IPv6
66
22
#[ derive( PartialEq , Eq , Debug ) ]
67
23
pub enum IPVersion {
0 commit comments