diff --git a/crates/librqbit/README.md b/crates/librqbit/README.md index 5eac475..4c6be0f 120000 --- a/crates/librqbit/README.md +++ b/crates/librqbit/README.md @@ -15,13 +15,22 @@ const MAGNET_LINK: &str = "magnet:?..."; // Put your magnet link here #[tokio::main] async fn main() -> Result<(), Box>{ - 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 { - AddTorrentResponse::Added(handle) => { - handle + Ok(AddTorrentResponse::Added(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?; Ok(())