readme code example can now compile
This commit is contained in:
parent
559bb3a194
commit
44868183fb
1 changed files with 14 additions and 5 deletions
|
|
@ -15,13 +15,22 @@ const MAGNET_LINK: &str = "magnet:?..."; // Put your magnet link here
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn Error>>{
|
async fn main() -> Result<(), Box<dyn Error>>{
|
||||||
|
|
||||||
let session = Session::new("C:\\Anime", Default::default());
|
// Create the session
|
||||||
|
let session = Session::new("C:\\Anime".parse().unwrap(), BlockingSpawner::new(false)).await?;
|
||||||
|
|
||||||
|
// Add the torrent to the session
|
||||||
let handle = match session.add_torrent(MAGNET_LINK, None).await {
|
let handle = match session.add_torrent(MAGNET_LINK, None).await {
|
||||||
AddTorrentResponse::Added(handle) => {
|
Ok(AddTorrentResponse::Added(handle)) => {
|
||||||
handle
|
Ok(handle)
|
||||||
},
|
},
|
||||||
resp => unimplemented!("{:?}", resp)
|
Err(e) => {
|
||||||
};
|
eprintln!("Something goes wrong when downloading torrent : {:?}", e);
|
||||||
|
Err(())
|
||||||
|
}
|
||||||
|
_ => Err(())
|
||||||
|
}.expect("Failed to add torrent to the session");
|
||||||
|
|
||||||
|
// Wait until the download is completed
|
||||||
handle.wait_until_completed().await?;
|
handle.wait_until_completed().await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue