lt_rs/alerts/implementations/
add_torrent.rs

1use crate::{
2    add_torrent_params::AddTorrentParamsRef,
3    alerts::AddTorrentAlert,
4    errors::LtrsError,
5    ffi::alerts::add_torrent::ffi::{
6        add_torrent_alert_get_add_torrent_params, add_torrent_alert_get_error,
7    },
8    torrent_handle::TorrentHandle,
9};
10
11impl AddTorrentAlert {
12    #[inline(always)]
13    pub fn handle(&self) -> TorrentHandle {
14        self.as_torrent_alert().handle()
15    }
16
17    #[inline(always)]
18    pub fn torrent_name<'a>(&'a self) -> &'a str {
19        self.as_torrent_alert().torrent_name()
20    }
21
22    #[inline(always)]
23    pub fn message(&self) -> String {
24        self.as_torrent_alert().message()
25    }
26
27    /// This contains copies of the most important fields from the original add_torrent_params
28    /// object, passed to add_torrent() or async_add_torrent(). Specifically, these fields are copied:
29    ///
30    /// * version
31    /// * ti
32    /// * name
33    /// * save_path
34    /// * userdata
35    /// * tracker_id
36    /// * flags
37    /// * info_hash
38    #[inline(always)]
39    pub fn params<'a>(&'a self) -> AddTorrentParamsRef<'a> {
40        unsafe { add_torrent_alert_get_add_torrent_params(self.0) }.into()
41    }
42
43    #[inline(always)]
44    pub fn error(&self) -> LtrsError {
45        unsafe { add_torrent_alert_get_error(self.0) }.into()
46    }
47}