0.3.2 |
|
---|---|
0.3.1 |
|
0.3.0 |
|
0.2.0 |
|
0.1.0 |
|
#403 在 #api-wrapper
97 每月下载量
18KB
321 代码行
Helldivers Rust API包装器
重命名为helldive_rs
非官方Helldivers API的Rust包装器。此库提供了一个轻松与Helldivers API交互并检索有关战争、星球、派系和区域信息的方式。
请注意,Helldivers API是非官方的,可能会随时更改。随着API的反向工程,将添加更多功能。
此库与Arrowhead Game Studios或Sony Interactive Entertainment无关。
安装
在项目目录中运行以下Cargo命令
cargo add helldivers_rs
或将以下行添加到您的Cargo.toml文件中
[dependencies]
helldivers_rs = "0.3"
API参考
此库提供以下功能
get_status(war_id: i64, language: &str) -> Result<Status, reqwest::Error>: Get the current status of a war.
get_war_info(war_id: i64) -> Result<WarInfo, reqwest::Error>: Get information about a specific war.
get_planet_name(id: i64) -> String: Get the name of a planet by its ID.
get_faction_name(id: i64) -> String: Get the name of a faction by its ID.
get_sector_name(id: i64) -> String: Get the name of a sector by its ID.
有关结构和其字段的更多详细信息,请参阅源代码文档。
示例
use helldivers_rs;
use tokio;
#[tokio::main]
async fn main() {
// Get the current status of a war
let war_id = 801; // The war ID for the current war
let status = helldivers_rs::get_status(war_id, "en-US").await.unwrap();
println!("Current Message: {}", status.global_events[0].message);
// Get information about a specific war
let war_info = helldivers_rs::get_war_info(war_id).await.unwrap();
println!("War Start Date: {}", war_info.start_date);
// Get the name of a planet by ID
let planet_id = 0;
let planet_name = helldivers_rs::get_planet_name(planet_id);
println!("Planet Name: {}", planet_name);
// Get the name of a faction by ID
let faction_id = 1;
let faction_name = helldivers_rs::get_faction_name(faction_id);
println!("Faction Name: {}", faction_name);
// Get the name of a sector by ID
let sector_id = 0;
let sector_name = helldivers_rs::get_sector_name(sector_id);
println!("Sector Name: {}", sector_name);
}
贡献
欢迎贡献!如果您发现任何问题或有改进建议,请在此GitHub存储库中提交问题或拉取请求。
许可证
本项目采用MIT许可证。
依赖关系
~6–21MB
~278K SLoC