lt_rs/alerts/implementations/
scrape_reply.rs

1use crate::{
2    alerts::{ScrapeReplyAlert, protocol_version::ProtocolVersion},
3    ffi::alerts::scrape_reply::ffi::{
4        scrape_reply_alert_get_complete, scrape_reply_alert_get_incomplete,
5        scrape_reply_alert_get_version,
6    },
7    torrent_handle::TorrentHandle,
8};
9
10impl ScrapeReplyAlert {
11    #[inline(always)]
12    pub fn handle(&self) -> TorrentHandle {
13        self.as_torrent_alert().handle()
14    }
15
16    #[inline(always)]
17    pub fn torrent_name<'a>(&'a self) -> &'a str {
18        self.as_torrent_alert().torrent_name()
19    }
20
21    #[inline(always)]
22    pub fn message(&self) -> String {
23        self.as_torrent_alert().message()
24    }
25
26    #[inline(always)]
27    pub fn tracker_url<'a>(&'a self) -> &'a str {
28        self.as_tracker_alert().tracker_url()
29    }
30
31    #[inline(always)]
32    pub fn local_endpoint(&self) {
33        self.as_tracker_alert().local_endpoint()
34    }
35
36    #[inline(always)]
37    pub fn version(&self) -> ProtocolVersion {
38        ProtocolVersion::from_u8(unsafe { scrape_reply_alert_get_version(self.0) })
39    }
40
41    #[inline(always)]
42    pub fn complete(&self) -> i32 {
43        unsafe { scrape_reply_alert_get_complete(self.0) }
44    }
45
46    #[inline(always)]
47    pub fn incomplete(&self) -> i32 {
48        unsafe { scrape_reply_alert_get_incomplete(self.0) }
49    }
50}