6 releases

0.1.5 Apr 26, 2025
0.1.4 Apr 23, 2025
0.1.1 Jan 13, 2025

#138 in WebSocket

Download history 74/week @ 2025-03-31 58/week @ 2025-04-07 158/week @ 2025-04-14 248/week @ 2025-04-21 51/week @ 2025-04-28 7/week @ 2025-05-05 17/week @ 2025-05-12 6/week @ 2025-05-19

409 downloads per month

MIT license

32KB
836 lines

Aria2-rs

Crates.io

Yet Another Aria2 JSON-RPC Client. Inspired by aria2-rs

Features

  • Simple direct call via websocket.
  • Notification from websocket.

example

download a file and print taks status.

use aria2_rs_yet::{Client, ConnectionMeta, Result};
use aria2_rs_yet::call::{AddUri, TellStatus, TellStatusField};
use aria2_rs_yet::options::Aria2Options;

#[tokio::main]
async fn main() -> Result<()> {
    tracing_subscriber::fmt().with_max_level(tracing::Level::INFO).init();
    
    let (client, _) = Client::connect(
        ConnectionMeta::new(
            "ws://localhost:6800/jsonrpc",
            Some("<rpc-secret>"),
        )
    ).await?;

    let gid = client.call(
        AddUri::new(
            vec!["https://github.com/hxzhao527/aria2-rs-yet/archive/refs/heads/master.zip"],
            Some(Aria2Options{
                dir: Some("/tmp".to_string()),
                out: Some("aria2-rs-yet.zip".to_string()),
                ..Default::default()
            }),
            None,
        )
    ).await?;
    println!("{:?}", gid);

    let status = client.call(
        TellStatus::new(gid).fields(Some([TellStatusField::Status, TellStatusField::Gid]))
    ).await?;
    println!("{:?}", status);

    // drop(client); // uncomment this line to see the client disconnecting
    println!("waiting for ctrl-c");
    tokio::signal::ctrl_c().await.unwrap();
    Ok(())
}

License

MIT License

Dependencies

~5–14MB
~162K SLoC