This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is webex-rust, an asynchronous Rust library providing a minimal interface to Webex Teams APIs. It's designed primarily for building bots but supports general API interactions.
cargo build- Build the librarycargo test- Run unit testscargo clippy- Run linter (note: very strict clippy rules enabled)cargo fmt- Format codecargo doc- Generate documentation
cargo run --example hello-world- Basic message sending examplecargo run --example auto-reply- Bot that automatically replies to messagescargo run --example adaptivecard- Demonstrates AdaptiveCard usagecargo run --example device-authentication- Shows device authentication flow
cargo test --lib- Run library tests onlycargo clippy --all-targets --all-features- Full clippy checkcargo build --all-targets- Build everything including examples
./hooks/install.sh- Install pre-commit hooks that automatically run cargo fmt- Pre-commit hook ensures code is formatted before each commit
Webexstruct (src/client/mod.rs) - Main API client with token-based authenticationWebexEventStream(src/client/websocket.rs) - WebSocket event stream handler for real-time eventsRestClient(src/client/rest.rs) - Low-level HTTP client wrapper with flexible authentication- Client module (
src/client/) - Client implementation split into modular components - Types module (
src/types/) - All API data structures organized by resource type - AdaptiveCard module (
src/adaptive_card/) - Support for interactive cards with builders - Auth module (
src/auth.rs) - Device authentication flows (OAuth device grant) - Error module (
src/error.rs) - Comprehensive error handling
- Generic API methods:
get<T>(),list<T>(),delete<T>()work with anyGettabletype - Device registration: Automatic device setup and caching for WebSocket connections
- Message handling: Supports both direct messages and room messages with threading
- Event streaming: WebSocket-based real-time event processing with automatic reconnection
- Token-based authentication for REST API calls
- Device registration with Webex for WebSocket connections
- Mercury URL discovery for optimal WebSocket endpoint
- Automatic device cleanup and recreation as needed
- Uses Rust 1.92 toolchain (see
rust-toolchain.toml) - Very strict clippy configuration with pedantic and nursery lints enabled
- All public APIs must have documentation (
#![deny(missing_docs)]) - WebSocket connections require device registration and token authentication
- Mercury URL caching reduces API calls for device discovery
- Comprehensive CI workflow with tests, clippy, fmt, build, and doc checks
- Git pre-commit hooks available in
hooks/directory to auto-format code
- Module organization: Refactored large files into logical modules
src/lib.rsreduced from 1532 lines to 54 lines (thin orchestrator)src/client/module split intomod.rs,rest.rs, andwebsocket.rssrc/types/module organized by resource type (message, room, person, etc.)src/adaptive_card/module split into elements, containers, and styles
- Backward compatibility: All public APIs maintained, including Clone trait on Webex struct
- Test coverage: 37 unit tests ensuring functionality after refactoring
- Documentation: Fixed broken doc links, cargo doc builds with zero warnings