rqbit/crates/librqbit/README.md

30 lines
770 B
Markdown
Raw Normal View History

2023-11-15 19:53:50 +01:00
# librqbit
A torrent library 100% written in rust
## Basic example
2023-11-15 20:21:30 +01:00
This is a simple program on how to use this library
2023-11-15 19:53:50 +01:00
This program will just download a simple torrent file with a Magnet link
```rust
use std::error::Error;
2023-11-15 20:27:02 +01:00
use librqbit::session::{AddTorrentResponse, Session};
2023-11-15 19:53:50 +01:00
const MAGNET_LINK: &str = "magnet:?..."; // Put your magnet link here
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>>{
2023-11-15 20:27:02 +01:00
let session = Session::new("C:\\Anime", Default::default());
2023-11-15 19:53:50 +01:00
let handle = match session.add_torrent(MAGNET_LINK, None).await {
2023-11-15 20:27:02 +01:00
AddTorrentResponse::Added(handle) => {
handle
},
resp => unimplemented!("{:?}", resp)
2023-11-15 19:53:50 +01:00
};
2023-11-15 20:27:02 +01:00
handle.wait_until_completed().await?;
2023-11-15 19:53:50 +01:00
Ok(())
}
```