2个不稳定版本

使用旧的Rust 2015

0.2.0 2018年11月25日
0.1.0 2018年8月26日

#512 in HTTP客户端

ISC 许可证

37KB
364

ci-badge license-badge docs-badge rust badge

aur

aur 是一个用于与 [Arch用户仓库] RPC API 交互的包。

它支持异步 hyper 和同步 reqwest 的客户端特性行实现。

安装

此库需要至少Rust 1.26.0。

将以下内容添加到您的 Cargo.toml

[dependencies]
aur = "~0.1"

并将以下内容添加到您的 main.rslib.rs

extern crate aur;

有两个功能:hyper-supportreqwest-support。默认启用 hyper-support。要启用 reqwest-support,请像这样依赖 aur

[dependencies.aur]
default-features = false
features = ["reqwest-support"]
version = "~0.1"

示例

异步请求 rust-nightly 包的信息

extern crate aur;
extern crate hyper;
extern crate hyper_rustls;
extern crate tokio_core;

use aur::bridge::hyper::AurRequester;
use hyper::Client;
use hyper_rustls::HttpsConnector;

let connector = HttpsConnector::new(4);
let client = Client::builder().build(connector);

let done = client.aur_search(Some("rust-nightly"), None).map(|search| {
    assert!(search.result_count >= 2);
}).map_err(|why| {
    println!("Error getting rust-nightly info: {:?}", why);
});

tokio::run(done);

同步请求 rust-nightly 包的信息

extern crate aur;
extern crate reqwest;

use aur::bridge::reqwest::AurRequester;
use reqwest::Client;

let client = Client::new();

let info = client.aur_info(&["rust-nightly"])?;

match info.first() {
    Some(package) => {
        if let Some(ref maintainer) = package.maintainer {
            println!("The package is maintained by: {}", maintainer);
        } else {
            println!("The package has no maintainer");
        }
    },
    None => {
        println!("No package found!");
    },
}

许可证

ISC.

依赖关系

~0.7–5MB
~103K SLoC