Skip to content

Commit

Permalink
Fix librqbit readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ikatson committed Nov 16, 2023
1 parent da3e6ab commit c10f4fc
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
40 changes: 40 additions & 0 deletions crates/librqbit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# librqbit

A torrent library 100% written in rust

## Basic example
This is a simple program on how to use this library
This program will just download a simple torrent file with a Magnet link

```rust
use std::error::Error;
use std::path::PathBuf;
use librqbit::session::{AddTorrentResponse, Session};
use librqbit::spawn_utils::BlockingSpawner;

const MAGNET_LINK: &str = "magnet:?..."; // Put your magnet link here

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>>{

// 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 {
Ok(AddTorrentResponse::Added(handle)) => {
Ok(handle)
},
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(())
}
```
7 changes: 7 additions & 0 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

find crates -maxdepth 1 -type d | grep '/' | while read dir; do
pushd "${dir}"
cargo publish --dry-run
popd
done

0 comments on commit c10f4fc

Please sign in to comment.