2.9 KiB
2.9 KiB
Repository Guidelines
Project Structure & Module Organization
common/: tonic/prost definitions; editproto/lesavka.protoand letbuild.rsregenerate bindings.server/: gRPC relay and media handling; entrypointsrc/main.rs; integration tests inserver/tests.client/: GTK + GStreamer desktop agent; input adapters live insrc/input, UVC output insrc/output, helpers/tests insrc/tests.scripts/:install/provisioning for Arch-based hosts,daemon/lesavka-core.shsystemd entrypoint,manual/diagnostics (VPN, USB reset, media capture).
Build, Test, and Development Commands
- Formatting:
cargo fmt --all --manifest-path client/Cargo.toml(repeat forserver/common). - Linting:
cargo clippy --all-targets --manifest-path server/Cargo.toml -D warnings(run for client too). - Build:
cargo build --all-targets --manifest-path server/Cargo.tomlandcargo build --all-targets --manifest-path client/Cargo.toml; building either pullscommon. - Tests:
cargo test --manifest-path server/Cargo.tomlruns async RPC tests;cargo test --manifest-path client/Cargo.tomlcovers keymap/unit cases. - Runtime:
cargo run --manifest-path server/Cargo.tomlto start the relay;LESAVKA_SERVER_ADDR=<host:port> cargo run --manifest-path client/Cargo.tomlto point the client at a server. - Provisioning:
scripts/install/server.shandscripts/install/client.shinstall dependencies and systemd units; rerun after changing installers or binary names.
Coding Style & Naming Conventions
- Rust 2024 with four-space indentation;
snake_casefor functions/modules,CamelCasefor types and Protobuf messages. - Keep RPC shapes defined in
common/proto/lesavka.proto; never hand-edit generated code intarget/orOUT_DIR. - Prefer tonic streaming APIs over manual channels; keep GStreamer/GTK wiring in small helpers to avoid sprawling
main.rs. - Use
tracingconsistently; defaultRUST_LOG=info,lesavka=debugfor local runs.
Testing Guidelines
- Async integration tests mirror
server/tests/hid.rsusing#[tokio::test]and an in-process tonic server/client pair. - Place client unit tests next to modules (
client/src/tests); name cases after behavior (keycode_to_usage_maps_letters,hid_roundtrip). - For new RPCs, add end-to-end assertions for request/response, stream termination, and error paths; prefer deterministic timeouts over sleeps.
Commit & Pull Request Guidelines
- Git history favors short, imperative subjects (
"install mic deps","client: improve mic defaults"); keep each commit focused. - Before opening a PR, run fmt, clippy, and tests for client and server; note any manual steps or env vars used (
LESAVKA_SERVER_ADDR,LESAVKA_UVC_DEV,LESAVKA_UAC_DEV). - PR descriptions should summarize intent, attach logs/screenshots when touching media paths, and flag installer/systemd changes so operators can re-run the relevant scripts.