2个版本
0.1.1 | 2020年5月18日 |
---|---|
0.1.0 | 2020年5月18日 |
#1275 in 文本处理
39KB
1K SLoC
目录
Vndbrs
简易的VNDB API
建议编写绕过此库的高级包装器,而不是直接使用。
用法
需要Rust 1.42
[dependencies]
vndb_rs = "0.1"
特性
- 所有API操作
- TLS支持
- 异步
示例
目前创建TCP流是在用户端。这可能需要更改。
登录并获取数据库统计信息
use std::net::TcpStream;
use vndb_rs::{
API_URL,
sync::client::Client,
};
let mut client = Client::new(TcpStream::connect(API_URL).unwrap());
let response = client.login();
println!("{:#?}", response);
let response = client.get_dbstats();
println!("{:#?}", response);
登录并获取ID为1的VN的所有信息
use std::net::TcpStream;
use vndb_rs::{
API_URL,
sync::client::Client,
get::vn::VN_FLAGS,
};
let mut client = Client::new(TcpStream::connect(API_URL).unwrap());
let response = client.login();
println!("{:#?}", response);
let response = client.get_vn(&VN_FLAGS, "(id=6540)".to_owned(), None);
println!("{:#?}", response);
使用凭据登录并将ID为17的VN的投票设置为8.5
use std::net::TcpStream;
use vndb_rs::{
API_URL,
sync::client::Client,
common::set::ulist::UListFields,
};
let mut client = Client::new(TcpStream::connect(API_URL).unwrap());
let response = client.login_with_credentials("username", "password");
println!("{:#?}", response);
let response = client.set_ulist(
"17".to_owned(),
UListFields::new(None, None, None, Some(85), None),
);
println!("{:#?}", response);
参考
依赖
~1.2–2MB
~41K SLoC