Howtos for The Rest of Us

Skills

Rust Standards

Coding conventions and patterns for the NotAlterra project.

Error Handling

File I/O

String Handling

Data Structures

Pattern: Property Extraction (GVAS parser)

All four extractors follow the same pattern:

  1. Scan for property name using windows(target.len()).position()
  2. Validate the FName header (length dword + null terminator)
  3. Skip past the property type name
  4. Validate bounds before every index access
  5. Return Option or Result - never panic

When adding a new property type, follow this exact pattern and add a bounds check on every array access.

Pattern: TUI Dialogs

All dialogs follow the same structure:

  1. Define popup area with centered_rect_size() or centered_rect()
  2. Render Clear widget, then a bordered Block
  3. Compute inner area with margin
  4. Render title, body, buttons in sequence
  5. Call draw_whale_separator(f, bar, app) at the bottom

Pattern: Menu Actions

All menu actions:

  1. Validate preconditions (save folder set, backup exists)
  2. Show status/spinner if the operation takes time
  3. Call through to ops::* for actual file operations
  4. Log via guard::log_action() with sanitized paths
  5. Show result dialog (success or error)
  6. Refresh dashboard stats

Clippy

Dependencies