lt_rs/alerts/implementations/
peer_error.rs1use crate::alerts::PeerErrorAlert;
2use crate::alerts::operation::Operation;
3use crate::alerts::peer_alert::{Endpoint, PeerId};
4use crate::errors::LtrsError;
5use crate::ffi::alerts::peer_error::ffi::{peer_error_alert_get_error, peer_error_alert_get_op};
6use crate::torrent_handle::TorrentHandle;
7
8impl PeerErrorAlert {
9 #[inline(always)]
10 pub fn handle(&self) -> TorrentHandle {
11 self.as_torrent_alert().handle()
12 }
13
14 #[inline(always)]
15 pub fn torrent_name<'a>(&'a self) -> &'a str {
16 self.as_torrent_alert().torrent_name()
17 }
18
19 #[inline(always)]
20 pub fn message(&self) -> String {
21 self.as_torrent_alert().message()
22 }
23
24 #[inline(always)]
25 pub fn pid(&self) -> PeerId {
26 self.as_peer_alert().peer_id()
27 }
28
29 #[inline(always)]
30 pub fn endpoint(&self) -> Endpoint {
31 self.as_peer_alert().endpoint()
32 }
33
34 #[inline(always)]
35 pub fn op(&self) -> Operation {
36 unsafe { peer_error_alert_get_op(self.0) }.into()
37 }
38
39 #[inline(always)]
40 pub fn error(&self) -> LtrsError {
41 unsafe { peer_error_alert_get_error(self.0) }.into()
42 }
43}