lt_rs/alerts/implementations/
block_downloading.rs

1use crate::alerts::BlockDownloadingAlert;
2use crate::alerts::peer_alert::{Endpoint, PeerId};
3use crate::ffi::alerts::block_downloading::ffi::{
4    block_downloading_alert_get_block_index, block_downloading_alert_get_piece_index,
5};
6use crate::ffi::ffi::PieceIndex;
7use crate::torrent_handle::TorrentHandle;
8
9impl BlockDownloadingAlert {
10    #[inline(always)]
11    pub fn handle(&self) -> TorrentHandle {
12        self.as_torrent_alert().handle()
13    }
14
15    #[inline(always)]
16    pub fn torrent_name<'a>(&'a self) -> &'a str {
17        self.as_torrent_alert().torrent_name()
18    }
19
20    #[inline(always)]
21    pub fn message(&self) -> String {
22        self.as_torrent_alert().message()
23    }
24
25    #[inline(always)]
26    pub fn pid(&self) -> PeerId {
27        self.as_peer_alert().peer_id()
28    }
29
30    #[inline(always)]
31    pub fn endpoint(&self) -> Endpoint {
32        self.as_peer_alert().endpoint()
33    }
34
35    #[inline(always)]
36    pub fn block_index(&self) -> i32 {
37        unsafe { block_downloading_alert_get_block_index(self.0) }
38    }
39
40    #[inline(always)]
41    pub fn piece_index(&self) -> PieceIndex {
42        unsafe { block_downloading_alert_get_piece_index(self.0) }
43    }
44}