pub struct Index { /* private fields */ }
Implementations§
Source§impl Index
impl Index
pub fn new( configuration: Arc<Configuration>, tracker_statistics_importer: Arc<StatisticsImporter>, tracker_service: Arc<Service>, user_repository: Arc<DbUserRepository>, category_repository: Arc<DbCategoryRepository>, torrent_repository: Arc<DbTorrentRepository>, torrent_info_repository: Arc<DbTorrentInfoRepository>, torrent_file_repository: Arc<DbTorrentFileRepository>, torrent_announce_url_repository: Arc<DbTorrentAnnounceUrlRepository>, torrent_tag_repository: Arc<DbTorrentTagRepository>, torrent_listing_repository: Arc<DbTorrentListingGenerator>, ) -> Self
Sourcepub async fn add_torrent(
&self,
torrent_request: AddTorrentRequest,
user_id: UserId,
) -> Result<TorrentId, ServiceError>
pub async fn add_torrent( &self, torrent_request: AddTorrentRequest, user_id: UserId, ) -> Result<TorrentId, ServiceError>
Adds a torrent to the index.
§Errors
This function will return an error if:
- Unable to get the user from the database.
- Unable to get torrent request from payload.
- Unable to get the category from the database.
- Unable to insert the torrent into the database.
- Unable to add the torrent to the whitelist.
Sourcepub async fn get_torrent(
&self,
info_hash: &InfoHash,
opt_user_id: Option<UserId>,
) -> Result<Torrent, ServiceError>
pub async fn get_torrent( &self, info_hash: &InfoHash, opt_user_id: Option<UserId>, ) -> Result<Torrent, ServiceError>
Gets a torrent from the Index.
§Errors
This function will return an error if unable to get the torrent from the database.
Sourcepub async fn delete_torrent(
&self,
info_hash: &InfoHash,
user_id: &UserId,
) -> Result<DeletedTorrentResponse, ServiceError>
pub async fn delete_torrent( &self, info_hash: &InfoHash, user_id: &UserId, ) -> Result<DeletedTorrentResponse, ServiceError>
Delete a Torrent from the Index
§Errors
This function will return an error if:
- Unable to get the user who is deleting the torrent (logged-in user).
- The user does not have permission to delete the torrent.
- Unable to get the torrent listing from it’s ID.
- Unable to delete the torrent from the database.
Sourcepub async fn get_torrent_info(
&self,
info_hash: &InfoHash,
opt_user_id: Option<UserId>,
) -> Result<TorrentResponse, ServiceError>
pub async fn get_torrent_info( &self, info_hash: &InfoHash, opt_user_id: Option<UserId>, ) -> Result<TorrentResponse, ServiceError>
Get torrent info from the Index
§Errors
This function will return an error if:
- Unable to get torrent ID.
- Unable to get torrent listing from id.
- Unable to get torrent category from id.
- Unable to get torrent files from id.
- Unable to get torrent info from id.
- Unable to get torrent announce url(s) from id.
Sourcepub async fn generate_torrent_info_listing(
&self,
request: &ListingRequest,
) -> Result<TorrentsResponse, ServiceError>
pub async fn generate_torrent_info_listing( &self, request: &ListingRequest, ) -> Result<TorrentsResponse, ServiceError>
It returns a list of torrents matching the search criteria.
§Errors
Returns a ServiceError::DatabaseError
if the database query fails.
Sourcepub async fn update_torrent_info(
&self,
info_hash: &InfoHash,
title: &Option<String>,
description: &Option<String>,
category_id: &Option<CategoryId>,
tags: &Option<Vec<TagId>>,
user_id: &UserId,
) -> Result<TorrentResponse, ServiceError>
pub async fn update_torrent_info( &self, info_hash: &InfoHash, title: &Option<String>, description: &Option<String>, category_id: &Option<CategoryId>, tags: &Option<Vec<TagId>>, user_id: &UserId, ) -> Result<TorrentResponse, ServiceError>
Update the torrent info on the Index.
§Errors
This function will return an error if:
- Unable to get the user.
- Unable to get listing from id.
- Unable to update the torrent tile or description.
- User does not have the permissions to update the torrent.
Auto Trait Implementations§
impl Freeze for Index
impl !RefUnwindSafe for Index
impl Send for Index
impl Sync for Index
impl Unpin for Index
impl !UnwindSafe for Index
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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