# Build entire workspace
cargo build
# Build release
cargo build --release
# Build specific crate
cargo build -p engine_core
cargo build -p engine
# Check (faster than build)
cargo check
cargo check --all# Run all tests
cargo test
# Run tests for specific crate
cargo test -p engine_core
cargo test -p bus
# Run a single test by name
cargo test it_works
cargo test it_works -p engine_core
# Run tests with output
cargo test -- --nocapture
# Run ignored tests
cargo test -- --ignored# Run Clippy (linting)
cargo clippy
cargo clippy --all-targets --all-features
# Fix auto-fixable issues
cargo clippy --fix
# Check formatting
cargo fmt -- --check
# Format code
cargo fmtengine/- Main application binaryengine_core/- Core types (Event, EventKind, Plugin traits)bus/- Event bus/channel implementationrules/- Rule matching logicactions/- Action executionmetrics/- Metrics collection and HTTP endpointcore/- Additional core utilities
- Group imports: std lib first, then external crates, then internal modules
- Use
use crate::for internal imports - Example:
use std::time::Instant; use tokio::sync::mpsc; use crate::event::Event;
PascalCasefor types, traits, enums, structssnake_casefor functions, variables, modulesSCREAMING_SNAKE_CASEfor constantsPascalCasefor enum variants
- Derive common traits:
Debug,Clone,PartialEq,Eqwhere applicable - Use
pubexplicitly for exports - Prefer struct fields to be
pubwhen part of public API - Use
#[async_trait]for async trait methods
- Use
Resultfor recoverable errors - Use
expect()orunwrap()only in tests or when truly infallible - Propagate errors with
?operator - Use
let _ =when intentionally ignoring results
- Use
tokioruntime (#[tokio::main]) - Prefer
mpscchannels for communication - Use
async_trait::async_traitfor trait async methods
- 4 spaces for indentation
- Max line length: 100 characters (default rustfmt)
- Trailing commas in multi-line structs/enums
- Place tests in
#[cfg(test)]module at bottom of file - Use
use super::*;in test modules - Name tests descriptively (e.g.,
it_works,test_event_matching)
tokio- Async runtime (usefeatures = ["full"]for binaries, minimal for libs)uuid- UUID generation (features = ["v4"])async-trait- Async trait support
This project uses Rust 2024 edition.