114 lines
No EOL
2.5 KiB
Markdown
114 lines
No EOL
2.5 KiB
Markdown
# BotLib Development Guide
|
|
|
|
**Version:** 6.2.0
|
|
**Purpose:** Shared library for General Bots workspace
|
|
|
|
---
|
|
|
|
## ZERO TOLERANCE POLICY
|
|
|
|
**EVERY SINGLE WARNING MUST BE FIXED. NO EXCEPTIONS.**
|
|
|
|
---
|
|
|
|
## ❌ ABSOLUTE PROHIBITIONS
|
|
|
|
```
|
|
❌ NEVER use #![allow()] or #[allow()] in source code
|
|
❌ NEVER use _ prefix for unused variables - DELETE or USE them
|
|
❌ NEVER use .unwrap() - use ? or proper error handling
|
|
❌ NEVER use .expect() - use ? or proper error handling
|
|
❌ NEVER use panic!() or unreachable!()
|
|
❌ NEVER use todo!() or unimplemented!()
|
|
❌ NEVER leave unused imports or dead code
|
|
❌ NEVER add comments - code must be self-documenting
|
|
```
|
|
|
|
---
|
|
|
|
## 🏗️ MODULE STRUCTURE
|
|
|
|
```
|
|
src/
|
|
├── lib.rs # Public exports, feature gates
|
|
├── error.rs # Error types (thiserror)
|
|
├── models.rs # Shared data models
|
|
├── message_types.rs # Message type definitions
|
|
├── http_client.rs # HTTP client wrapper (feature-gated)
|
|
├── branding.rs # Version, branding constants
|
|
└── version.rs # Version information
|
|
```
|
|
|
|
---
|
|
|
|
## ✅ MANDATORY CODE PATTERNS
|
|
|
|
### Error Handling
|
|
|
|
```rust
|
|
// ❌ WRONG
|
|
let value = something.unwrap();
|
|
|
|
// ✅ CORRECT
|
|
let value = something?;
|
|
let value = something.ok_or_else(|| Error::NotFound)?;
|
|
```
|
|
|
|
### Self Usage
|
|
|
|
```rust
|
|
impl MyStruct {
|
|
fn new() -> Self { Self { } } // ✅ Not MyStruct
|
|
}
|
|
```
|
|
|
|
### Format Strings
|
|
|
|
```rust
|
|
format!("Hello {name}") // ✅ Not format!("{}", name)
|
|
```
|
|
|
|
### Display vs ToString
|
|
|
|
```rust
|
|
// ❌ WRONG
|
|
impl ToString for MyType { }
|
|
|
|
// ✅ CORRECT
|
|
impl std::fmt::Display for MyType { }
|
|
```
|
|
|
|
### Derive Eq with PartialEq
|
|
|
|
```rust
|
|
#[derive(PartialEq, Eq)] // ✅ Always both
|
|
struct MyStruct { }
|
|
```
|
|
|
|
---
|
|
|
|
## 📦 KEY DEPENDENCIES
|
|
|
|
| Library | Version | Purpose |
|
|
|---------|---------|---------|
|
|
| anyhow | 1.0 | Error handling |
|
|
| thiserror | 2.0 | Error derive |
|
|
| chrono | 0.4 | Date/time |
|
|
| serde | 1.0 | Serialization |
|
|
| uuid | 1.11 | UUIDs |
|
|
| diesel | 2.1 | Database ORM |
|
|
| reqwest | 0.12 | HTTP client |
|
|
|
|
---
|
|
|
|
## 🔑 REMEMBER
|
|
|
|
- **ZERO WARNINGS** - Every clippy warning must be fixed
|
|
- **NO ALLOW IN CODE** - Never use #[allow()] in source files
|
|
- **NO DEAD CODE** - Delete unused code
|
|
- **NO UNWRAP/EXPECT** - Use ? operator
|
|
- **INLINE FORMAT ARGS** - `format!("{name}")` not `format!("{}", name)`
|
|
- **USE SELF** - In impl blocks, use Self not the type name
|
|
- **DERIVE EQ** - Always derive Eq with PartialEq
|
|
- **DISPLAY NOT TOSTRING** - Implement Display, not ToString
|
|
- **Version 6.2.0** - do not change without approval |