|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +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. |
| 8 | + |
| 9 | +## Commands |
| 10 | + |
| 11 | +### Build and Test |
| 12 | +- `cargo build` - Build the library |
| 13 | +- `cargo test` - Run unit tests |
| 14 | +- `cargo clippy` - Run linter (note: very strict clippy rules enabled) |
| 15 | +- `cargo fmt` - Format code |
| 16 | +- `cargo doc` - Generate documentation |
| 17 | + |
| 18 | +### Examples |
| 19 | +- `cargo run --example hello-world` - Basic message sending example |
| 20 | +- `cargo run --example auto-reply` - Bot that automatically replies to messages |
| 21 | +- `cargo run --example adaptivecard` - Demonstrates AdaptiveCard usage |
| 22 | +- `cargo run --example device-authentication` - Shows device authentication flow |
| 23 | + |
| 24 | +### Development |
| 25 | +- `cargo test --lib` - Run library tests only |
| 26 | +- `cargo clippy --all-targets --all-features` - Full clippy check |
| 27 | +- `cargo build --all-targets` - Build everything including examples |
| 28 | + |
| 29 | +## Architecture |
| 30 | + |
| 31 | +### Core Components |
| 32 | + |
| 33 | +- **`Webex` struct** (`src/lib.rs:92-100`) - Main API client with token-based authentication |
| 34 | +- **`WebexEventStream`** (`src/lib.rs:102-108`) - WebSocket event stream handler for real-time events |
| 35 | +- **`RestClient`** (`src/lib.rs:247-251`) - Low-level HTTP client wrapper |
| 36 | +- **Types module** (`src/types.rs`) - All API data structures and serialization |
| 37 | +- **AdaptiveCard module** (`src/adaptive_card.rs`) - Support for interactive cards |
| 38 | +- **Auth module** (`src/auth.rs`) - Device authentication flows |
| 39 | +- **Error module** (`src/error.rs`) - Comprehensive error handling |
| 40 | + |
| 41 | +### Key Patterns |
| 42 | + |
| 43 | +- **Generic API methods**: `get<T>()`, `list<T>()`, `delete<T>()` work with any `Gettable` type |
| 44 | +- **Device registration**: Automatic device setup and caching for WebSocket connections |
| 45 | +- **Message handling**: Supports both direct messages and room messages with threading |
| 46 | +- **Event streaming**: WebSocket-based real-time event processing with automatic reconnection |
| 47 | + |
| 48 | +### Authentication Flow |
| 49 | + |
| 50 | +1. Token-based authentication for REST API calls |
| 51 | +2. Device registration with Webex for WebSocket connections |
| 52 | +3. Mercury URL discovery for optimal WebSocket endpoint |
| 53 | +4. Automatic device cleanup and recreation as needed |
| 54 | + |
| 55 | +## Important Notes |
| 56 | + |
| 57 | +- Uses Rust 1.76 toolchain (see `rust-toolchain.toml`) |
| 58 | +- Very strict clippy configuration with pedantic and nursery lints enabled |
| 59 | +- All public APIs must have documentation (`#![deny(missing_docs)]`) |
| 60 | +- WebSocket connections require device registration and token authentication |
| 61 | +- Mercury URL caching reduces API calls for device discovery |
0 commit comments