From c10f4fcd1b27142e64f9977a019884410887f3ec Mon Sep 17 00:00:00 2001 From: Igor Katson Date: Thu, 16 Nov 2023 07:47:00 +0000 Subject: [PATCH] Fix librqbit readme --- crates/librqbit/README.md | 40 +++++++++++++++++++++++++++++++++++++++ scripts/publish.sh | 7 +++++++ 2 files changed, 47 insertions(+) create mode 100644 crates/librqbit/README.md create mode 100755 scripts/publish.sh diff --git a/crates/librqbit/README.md b/crates/librqbit/README.md new file mode 100644 index 00000000..dfa4845f --- /dev/null +++ b/crates/librqbit/README.md @@ -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>{ + + // 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(()) +} +``` \ No newline at end of file diff --git a/scripts/publish.sh b/scripts/publish.sh new file mode 100755 index 00000000..dc1424e0 --- /dev/null +++ b/scripts/publish.sh @@ -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 \ No newline at end of file