@@ -42,24 +42,28 @@ pub struct TorrentInfo {
4242impl TorrentInfo {
4343 /// torrent file can only hold a pieces key or a root hash key:
4444 /// http://www.bittorrent.org/beps/bep_0030.html
45+ #[ must_use]
4546 pub fn get_pieces_as_string ( & self ) -> String {
4647 match & self . pieces {
47- None => "" . to_string ( ) ,
48+ None => String :: new ( ) ,
4849 Some ( byte_buf) => bytes_to_hex ( byte_buf. as_ref ( ) ) ,
4950 }
5051 }
5152
53+ #[ must_use]
5254 pub fn get_root_hash_as_i64 ( & self ) -> i64 {
5355 match & self . root_hash {
5456 None => 0i64 ,
5557 Some ( root_hash) => root_hash. parse :: < i64 > ( ) . unwrap ( ) ,
5658 }
5759 }
5860
61+ #[ must_use]
5962 pub fn is_a_single_file_torrent ( & self ) -> bool {
6063 self . length . is_some ( )
6164 }
6265
66+ #[ must_use]
6367 pub fn is_a_multiple_file_torrent ( & self ) -> bool {
6468 self . files . is_some ( )
6569 }
@@ -90,6 +94,7 @@ pub struct Torrent {
9094}
9195
9296impl Torrent {
97+ #[ must_use]
9398 pub fn from_db_info_files_and_announce_urls (
9499 torrent_info : DbTorrentInfo ,
95100 torrent_files : Vec < TorrentFile > ,
@@ -170,6 +175,7 @@ impl Torrent {
170175 }
171176 }
172177
178+ #[ must_use]
173179 pub fn calculate_info_hash_as_bytes ( & self ) -> [ u8 ; 20 ] {
174180 let info_bencoded = ser:: to_bytes ( & self . info ) . unwrap ( ) ;
175181 let mut hasher = Sha1 :: new ( ) ;
@@ -180,10 +186,12 @@ impl Torrent {
180186 sum_bytes
181187 }
182188
189+ #[ must_use]
183190 pub fn info_hash ( & self ) -> String {
184191 bytes_to_hex ( & self . calculate_info_hash_as_bytes ( ) )
185192 }
186193
194+ #[ must_use]
187195 pub fn file_size ( & self ) -> i64 {
188196 if self . info . length . is_some ( ) {
189197 self . info . length . unwrap ( )
@@ -201,6 +209,7 @@ impl Torrent {
201209 }
202210 }
203211
212+ #[ must_use]
204213 pub fn announce_urls ( & self ) -> Vec < String > {
205214 if self . announce_list . is_none ( ) {
206215 return vec ! [ self . announce. clone( ) . unwrap( ) ] ;
@@ -214,10 +223,12 @@ impl Torrent {
214223 . collect :: < Vec < String > > ( )
215224 }
216225
226+ #[ must_use]
217227 pub fn is_a_single_file_torrent ( & self ) -> bool {
218228 self . info . is_a_single_file_torrent ( )
219229 }
220230
231+ #[ must_use]
221232 pub fn is_a_multiple_file_torrent ( & self ) -> bool {
222233 self . info . is_a_multiple_file_torrent ( )
223234 }
0 commit comments