rusty-lcu
A library for interacting with the LCU API in Rust. It provides a typed interface to the LCU endpoints, as well as utilities for polling, event streams, and credential management.
The endpoint layer is generated from schema/swagger.json, which is vendored
from the Dysolix LCU swagger data. To regenerate from a newer schema, run
scripts\update-swagger.ps1 on Windows or ./scripts/update-swagger.sh on
Unix-like shells, then build normally. You can also set LCU_SWAGGER_PATH
before building to generate from another local schema without replacing the
vendored file.
Quick Start
use ;
async
Path, Query, And Body Params
Generated functions take EndpointParams so every swagger endpoint has the same
stable call shape. Endpoints with a named swagger response model also get a
*_typed helper that returns a generated models::* type. Endpoints with a
named swagger request body model also get *_with_body helpers, and endpoints
with both named request and response models get *_with_body_typed.
Required path parameters and required query parameters from the swagger are
validated before the request is sent.
let summoner = get_lol_summoner_v1_summoners_by_id
.await?;
let typed_summoner = get_lol_summoner_v1_summoners_by_id_typed
.await?;
let result = post_lol_lobby_v2_lobby
.await?;
let conversation: LolChatConversationResource = todo!;
let updated = put_lol_chat_v1_conversations_by_id_with_body_typed
.await?;
For raw escape-hatch calls, use client.get, client.post, client.put,
client.patch, client.delete, or client.request. Typed raw helpers are
available as get_as, post_as, put_as, patch_as, delete_as, and
request_as.
let phase: String = client
.get_as
.await?;
Endpoint Discovery
use ;
let endpoint = find_endpoint
.expect;
println!;
println!;
for endpoint in endpoints_for_tag
println!;
You can also inspect the generated surface without a running League client:
cargo run --example list_endpoints
With League running, this example connects to LCU and fetches the current summoner through a generated typed endpoint:
cargo run --example current_summoner
Polling
use ;
client
.poll_endpoint
.await?;
Credentials
By default connect() tries to read credentials from the running
LeagueClientUx process, falls back to the League lockfile at
C:\Riot Games\League of Legends\lockfile on Windows, and waits for LCU to
respond. You can override the lockfile with RUSTY_LCU_LOCKFILE, pass a
specific lockfile path, pass lockfile content, or construct manual credentials:
use ;
let mut client = new?;
client
.connect_with
.await?;
Use connect_with_options to disable or customize the readiness check:
use ;
let mut client = new?;
client
.connect_with_options
.await?;
Events
use Deserialize;
use ;
;
let mut events = client.event_stream.await?;
events.subscribe.await?;
let filter = new
.uri
.event_type;
while let Some = events..await?
Current Scope
This crate currently generates endpoint functions, endpoint metadata, and Rust
models for the full swagger surface. Generic functions return serde_json::Value;
typed helpers are generated where a request or response points at a named
swagger component schema. Exotic inline OpenAPI shapes are represented as
serde_json::Value inside generated models.