waddling-errors 0.7.3

Structured, secure-by-default diagnostic codes for distributed systems with no_std and role-based documentation
Documentation
# Feature Flags

Waddling-errors is designed to be ultra-lightweight by default, with optional features that can be enabled as needed.

## Available Features

### `std` (enabled by default)
Standard library support. Disable for `no_std` environments.

```toml
waddling-errors = { version = "0.4", default-features = false }
```

### `hash`
Base62 hashing for error codes using ahash.

- **Adds dependency**: ahash (~30KB)
- **Provides**: `Code::hash()` method
- **Use case**: Generate short, stable identifiers for error codes

```toml
waddling-errors = { version = "0.4", features = ["hash"] }
```

**Example:**
```rust
use waddling_errors::prelude::*;

const ERR: Code<Component, Primary> = Code::error(Component::Parser, Primary::Syntax, 3);
println!("Hash: {}", ERR.hash()); // e.g., "LlLyl" - 5-char base62
```

### `emoji`
Unicode emoji representation for severities.

- **Adds dependency**: None (zero-cost)
- **Provides**: `Severity::emoji()` method
- **Use case**: Modern terminal UIs, visual logs, documentation
- **Size impact**: ~200 bytes (const strings)

```toml
waddling-errors = { version = "0.4", features = ["emoji"] }
```

**Emoji mapping:**
- ❌ Error
- 🚫 Blocked
- 🔥 Critical
- ⚠️ Warning
- ✅ Success
- ✔️ Completed
- ℹ️ Info
- 🔍 Trace

### `ansi-colors`
ANSI escape codes for terminal colors.

- **Adds dependency**: None (zero-cost)
- **Provides**: `Severity::ansi_color()`, `Severity::ANSI_RESET`
- **Use case**: Colored terminal output
- **Size impact**: ~100 bytes (const strings)

```toml
waddling-errors = { version = "0.4", features = ["ansi-colors"] }
```

### `serde`
Serialization support for Severity and Code.

- **Adds dependency**: serde
- **Provides**: Serialize/Deserialize derives
- **Use case**: JSON APIs, configuration files, network protocols

```toml
waddling-errors = { version = "0.4", features = ["serde"] }
```

## Feature Combinations

### Minimal (no_std)
Zero dependencies, minimal footprint. Perfect for embedded systems.

```toml
waddling-errors = { version = "0.4", default-features = false }
```

**Available methods:**
- Trait-based error codes with `ComponentId` and `PrimaryId`
- All semantic methods: `is_blocking()`, `is_positive()`, `is_negative()`, `is_neutral()`
- Priority: `priority()`
- String conversion: `as_str()`, `description()`, `as_char()`
- Comparison: `Ord` implementation

### Visual Features
Emoji and ANSI colors for rich terminal output.

```toml
waddling-errors = { version = "0.4", features = ["emoji", "ansi-colors"] }
```

### Full Featured
All optional features enabled.

```toml
waddling-errors = { version = "0.4", features = ["hash", "emoji", "ansi-colors", "serde"] }
```

## Test Matrix

```bash
# Minimal build (9 tests)
cargo test --no-default-features

# With emoji (10 tests)
cargo test --no-default-features --features emoji

# With ANSI colors (10 tests)
cargo test --no-default-features --features ansi-colors

# All features (13 tests)
cargo test --all-features
```

## Design Philosophy

**Opt-in by default**: Every feature that adds code size or dependencies is behind a feature flag, even if the impact is minimal (~200 bytes for emoji).

**Zero-cost abstractions**: Visual features (emoji, ANSI colors) have zero runtime cost—they're just const string lookups with no allocations or dependencies.

**Pay only for what you use**: If you don't need visual representation, don't pay for it. If you don't need serialization, don't link serde.