pub struct Torrent {
pub info: TorrentInfo,
pub announce: Option<String>,
pub nodes: Option<Vec<TorrentNode>>,
pub encoding: Option<String>,
pub httpseeds: Option<Vec<String>>,
pub announce_list: Option<Vec<Vec<String>>>,
pub creation_date: Option<i64>,
pub comment: Option<String>,
pub created_by: Option<String>,
}
Fields§
§info: TorrentInfo
§announce: Option<String>
§nodes: Option<Vec<TorrentNode>>
§encoding: Option<String>
§httpseeds: Option<Vec<String>>
§announce_list: Option<Vec<Vec<String>>>
§creation_date: Option<i64>
§comment: Option<String>
§created_by: Option<String>
Implementations§
Source§impl Torrent
impl Torrent
Sourcepub fn from_db_info_files_and_announce_urls(
torrent_info: DbTorrentInfo,
torrent_files: Vec<TorrentFile>,
torrent_announce_urls: Vec<Vec<String>>,
) -> Self
pub fn from_db_info_files_and_announce_urls( torrent_info: DbTorrentInfo, torrent_files: Vec<TorrentFile>, torrent_announce_urls: Vec<Vec<String>>, ) -> Self
It hydrates a Torrent
struct from the database data.
§Panics
This function will panic if the torrent_info.pieces
is not a valid hex string.
Sourcepub async fn set_announce_urls(&mut self, cfg: &Configuration)
pub async fn set_announce_urls(&mut self, cfg: &Configuration)
Sets the announce url to the tracker url and removes all other trackers if the torrent is private.
Sourcepub fn calculate_info_hash_as_bytes(&self) -> [u8; 20]
pub fn calculate_info_hash_as_bytes(&self) -> [u8; 20]
It calculates the info hash of the torrent file.
§Panics
This function will panic if the info
part of the torrent file cannot be serialized.
pub fn info_hash(&self) -> String
pub fn file_size(&self) -> i64
Sourcepub fn announce_urls(&self) -> Vec<String>
pub fn announce_urls(&self) -> Vec<String>
It returns the announce urls of the torrent file.
§Panics
This function will panic if both the announce_list
and the announce
are None
.
pub fn is_a_single_file_torrent(&self) -> bool
pub fn is_a_multiple_file_torrent(&self) -> bool
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Torrent
impl<'de> Deserialize<'de> for Torrent
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Torrent
Auto Trait Implementations§
impl Freeze for Torrent
impl RefUnwindSafe for Torrent
impl Send for Torrent
impl Sync for Torrent
impl Unpin for Torrent
impl UnwindSafe for Torrent
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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