1 个不稳定版本
0.5.6 | 2024年4月16日 |
---|
322 在 游戏 中
105KB
2.5K SLoC
Irelia
Irelia 是一套基于 Hyper 构建的绑定到原生 LoL API 的工具集。
此软件包支持 Windows,macOS 支持未经测试。
请注意,从补丁 14.5 开始,League of Legends 在 wine 上将无法运行,因此该平台不再受支持
注意:irelia 中使用的 base64 编码器需要 .cargo/config.toml 文件,示例可在此找到 此处
Cargo 功能
此软件包旨在具有模块化,因此 API 支持已被拆分为不同的 cargo 功能。
默认情况下,此软件包仅启用了 rest 功能。
["full"]
- 启用对所有 API 的支持["ws"]
- 启用对 LCU websockets 的支持["in_game"]
- 启用对原生游戏 API 的支持["tauri]
- 在错误上派生序列化["batched"]
- 启用批处理请求系统
示例
use irelia::{RequestClient, rest::LCUClient};
use serde_json::Value;
/// Get the player from the client API
async fn get_summoner() -> Result<Option<Value>, LCUError> {
// Create a new general request client
let client = RequestClient::new();
// Pass the client to the LCU connection
let lcu_client = LCUClient::new()?;
// The return type must be defined
// And can be any struct that implements serde::Deserialize
client.get("/lol-summoner/v1/current-summoner", &client).await
}
use irelia::{RequestClient, in_game::InGameClient};
use serde_json::Value;
/// Get the player from the in game API
async fn get_in_game_summoner() -> Result<ActivePlayer, LCUError> {
// Create a new general request client
let client = RequestClient::new();
// Pass the client to the LCU connection
let game_client = InGameClient::new()?;
game_client.active_player(&client)
}
依赖项
~3–32MB
~488K SLoC