Crate rtorrent_xmlrpc_bindings
source · [−]Expand description
rtorrent-xmlrpc-bindings
rtorrent-xmlrpc-bindings
provides strongly-typed Rust bindings for the rtorrent XMLRPC API.
The XMLRPC API allows a high degree of introspection and control over an rtorrent instance.
Usage
The top-level structure representing an rtorrent instance is Server
. All errors produced by
the crate are encapsulated by the Error
type.
use rtorrent_xmlrpc_bindings as rtorrent;
let my_handle = rtorrent::Server::new("http://1.2.3.4/RPC2");
println!("Hostname: {}", my_handle.hostname()?);
for download in my_handle.download_list()? {
println!("Download: {}", download.name()?);
}
It can be more efficient to query multiple items at a time. Rtorrent’s XMLRPC API exposes an
interface for this called “multicalls.” In this crate, they are available through the
multicall
submodule.
The following example queries the name and ratio of every torrent in rtorrent’s “default” view and prints the results.
use rtorrent_xmlrpc_bindings as rtorrent;
use rtorrent::multicall::d;
let my_handle = rtorrent::Server::new("http://1.2.3.4/RPC2");
d::MultiBuilder::new(&my_handle, "default")
.call(d::NAME)
.call(d::RATIO)
.invoke()?
.iter()
.for_each(|(name, ratio)| {
println!("{}: ratio: {}", name, ratio);
});
Current Limitations
- Some XMLRPC APIs are not yet wrapped by this crate.
!
Modules
Rtorrent multicalls
Structs
Download
represents a loaded torrent
Server
represents a logical rtorrent instance
Enums
The unified error type for this crate.
Traits
Essentially TryFrom