Struct Index

Source
pub struct Index { /* private fields */ }

Implementations§

Source§

impl Index

Source

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

Source

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.
Source

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.

Source

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.
Source

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.
Source

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.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,