Struct torrust_index_backend::tracker::service::Service
source · pub struct Service { /* private fields */ }
Implementations§
source§impl Service
impl Service
pub async fn new( cfg: Arc<Configuration>, database: Arc<Box<dyn Database>> ) -> Service
sourcepub async fn whitelist_info_hash(
&self,
info_hash: String
) -> Result<(), ServiceError>
pub async fn whitelist_info_hash( &self, info_hash: String ) -> Result<(), ServiceError>
Add a torrent to the tracker whitelist.
Errors
Will return an error if the HTTP request failed (for example if the tracker API is offline) or if the tracker API returned an error.
sourcepub async fn remove_info_hash_from_whitelist(
&self,
info_hash: String
) -> Result<(), ServiceError>
pub async fn remove_info_hash_from_whitelist( &self, info_hash: String ) -> Result<(), ServiceError>
Remove a torrent from the tracker whitelist.
Errors
Will return an error if the HTTP request failed (for example if the tracker API is offline) or if the tracker API returned an error.
sourcepub async fn get_personal_announce_url(
&self,
user_id: UserId
) -> Result<String, ServiceError>
pub async fn get_personal_announce_url( &self, user_id: UserId ) -> Result<String, ServiceError>
Get personal tracker announce url of a user.
Eg: https://tracker:7070/USER_TRACKER_KEY
If the user doesn’t have a not expired tracker key, it will generate a new one and save it in the database.
Errors
Will return an error if the HTTP request to get generated a new user tracker key failed.
sourcepub async fn get_torrent_info(
&self,
info_hash: &str
) -> Result<TorrentInfo, ServiceError>
pub async fn get_torrent_info( &self, info_hash: &str ) -> Result<TorrentInfo, ServiceError>
Get torrent info from tracker.
Errors
Will return an error if the HTTP request to get torrent info fails or if the response cannot be parsed.