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.
Auto Trait Implementations§
impl Freeze for Service
impl !RefUnwindSafe for Service
impl Send for Service
impl Sync for Service
impl Unpin for Service
impl !UnwindSafe for Service
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more