9次发布
| 0.2.6 | 2022年5月13日 |
|---|---|
| 0.2.5 | 2022年5月11日 |
| 0.2.1 | 2022年4月28日 |
| 0.1.1 | 2022年4月27日 |
在 HTTP客户端 中排名第396
每月下载28次
11MB
226K SLoC
GitHub v3 REST API
Rust的GitHub API客户端,支持hyper和reqwest(异步和阻塞)。
此代码自动从GitHub API的OpenAPI规范生成。
功能
此代码至少需要启用一个功能,以选择HTTP请求库
hyper-client(默认启用)reqwest-asyncreqwest-blocking
贡献
由于此代码是自动生成的,因此不接受直接提交。
如果您发现问题,请检查GitHub的OpenAPI仓库中是否存在相同的问题,并在那里报告。
如果问题不存在于OpenAPI描述中,并且似乎是与代码生成有关的问题,请在此仓库中打开一个问题。
lib.rs:
GitHub API的客户端。
从https://github.com/github/rest-api-description/commits/main/descriptions/api.github.com/api.github.com.json SHA 6985b0b,2022年4月27日生成
HTTP库支持
可以通过功能选择底层Web库。
对于hyper,默认启用hyper-client功能。
对于异步reqwest使用
[dependencies]
jinxapi-github = { version = "0.1", default-features = false, features = ["reqwest-async"] }
对于阻塞reqwest使用
[dependencies]
jinxapi-github = { version = "0.1", default-features = false, features = ["reqwest-blocking"] }
使用API
大致来说,使用API的步骤如下
- 创建一个包含身份验证凭证的
v1_1_4::config::Configuration对象。 - 为底层HTTP库(
hyper或reqwest)创建客户端。 - 创建一个
Caller(v1_1_4::hyper::Caller,v1_1_4::reqwest::Caller,v1_1_4::reqwest::blocking::Caller),提供配置、客户端和适当的睡眠函数(例如std::thread::sleep或tokio::time::sleep)。 - 对于带有主体的请求,创建主体类型。
- 在
Caller上调用方法,传入操作参数,如果需要,还可以传入主体。 - 处理方法返回的响应。
依赖项
~8–21MB
~423K SLoC