This file provides guidance to WARP (warp.dev) when working with code in this repository.
This is the stardust-xr core library repository, providing the fundamental connection library between Stardust XR servers and clients. It consists of three main crates organized as a Cargo workspace:
- wire (
stardust-xr-wire): Base library for the Stardust XR display server with client/server connection handling - protocol (
stardust-xr-protocol): Protocol schemas generated from FlatBuffers and KDL protocol definitions - gluon (
stardust-xr-gluon): D-Bus object based utilities - fusion (
stardust-xr-fusion): High-level client library with abstractions for nodes and event loops
This is an XR (extended reality) framework that uses Unix domain sockets for client-server communication and supports spatial computing with 3D transformations, zones, input handling, and drawable objects.
# Build all crates in workspace
cargo build
# Build with all features
cargo build --all-features# Run all tests
cargo test
# Test specific crate
cargo test -p stardust-xr-fusion
# Run tests with tracing output
RUST_LOG=debug cargo test# Format code (uses hard tabs per rustfmt.toml)
cargo fmt
# Check formatting
cargo fmt --check
# Lint
cargo clippy
# Lint all targets and features
cargo clippy --all-targets --all-featuresThe schemas crate uses FlatBuffers for protocol definitions. To regenerate schemas:
# Set environment variable to enable schema regeneration
STARDUST_REGEN_FBS=1 cargo build -p stardust-xr-schemasThis requires flatc (FlatBuffers compiler) to be installed and available in PATH.
- Client/Server Connection: Unix domain socket communication via
runtime_dir()(typically/run/user/{uid}/stardust-{instance}) - Messaging: Asymmetric messenger system handling FlatBuffer/FlexBuffer serialized messages
- Scenegraph: Trait-based system for managing spatial hierarchies and node relationships
- Values: Common data structures for 3D math (using
mintfor interoperability)
- Node System: Hierarchical spatial nodes with aspects (traits) like
Spatial,Drawable,Input - Event Loop: Sync and async event loop patterns for handling server messages
- Client: Connection management and resource setup
- Aspects: Modular functionality via trait system (similar to components/mixins)
- KDL Protocols: Human-readable protocol definitions in
schemas/src/protocol/*.kdl - Code Generation: Procedural macros generate Rust code from protocol definitions
- FlatBuffers: Binary serialization for message passing
- Aspects: Server-side and client-side method/signal definitions
- Spatial Nodes: 3D transforms with parent-child relationships
- Zones: Areas that can capture and manipulate spatial objects across clients
- Aspects: Trait-like functionality that can be composed on nodes
- Signals: One-way communication (client→server or server→client)
- Methods: Request-response communication patterns
STARDUST_INSTANCE: Server instance number (default: 0)STARDUST_RES_PREFIXES: Resource path prefixes (colon-separated)STARDUST_REGEN_FBS: Enable FlatBuffer schema regeneration during build
- Use hard tabs for indentation (configured in
.editorconfigandrustfmt.toml) - Follow standard Rust naming conventions
- Protocol definitions use KDL format with snake_case identifiers
- Generated code uses PascalCase for types and snake_case for functions
- Error handling via
color-eyreandthiserror
Resources are resolved using prefix paths configured via:
- Runtime environment variable
STARDUST_RES_PREFIXES - Compile-time environment variable
STARDUST_RES_PREFIXES - Paths provided to
Client::setup_resources() - Project-local resources via
project_local_resources!("path")macro
tokio: Async runtime with Unix socket supportserde: Serialization frameworktracing: Structured loggingmint: 3D math type interoperabilitycolor-eyre: Error reporting
glam: 3D mathematics libraryzbus: D-Bus integration for system servicesxkbcommon: Keyboard mapping (optional feature)
flatbuffers: Binary serialization formatflexbuffers: Dynamic/schema-less serializationkdl: Human-readable data format for protocolszbus: D-Bus interface generation
Tests can be run individually:
cargo test --test client_connectThe project includes unit tests and integration tests. Some tests require a running Stardust XR server instance.