pf_foundation_utils 0.1.0

Foundation utilities for RAII patterns, resource management, and scoped operations
Documentation

Foundation Utils

Core foundational utilities for the PromptFleet Agents project. Provides zero-dependency, WASM-compatible patterns for:

  • RAII Guards: Automatic resource cleanup with Drop trait
  • Scoped Operations: Guaranteed setup/teardown patterns
  • Context Management: Thread-safe context propagation
  • Resource Management: Safe resource acquisition/release

Design Principles

  • Zero Dependencies: Pure Rust stdlib only
  • WASM Compatible: Designed for WebAssembly environments
  • Zero Cost: Compile-time abstractions with no runtime overhead
  • Exception Safe: Automatic cleanup even during panics
  • Type Safe: Compiler-enforced correctness

Usage

use foundation_utils::raii::Guard;
use foundation_utils::scoped::with_context;

// RAII guard for automatic cleanup
let _guard = Guard::new("my_resource", |r| {
    println!("Cleaning up: {}", r);
});

// Scoped access to a value (value drops when scope ends)
let result = with_context(42, |ctx| {
    ctx + 1
});
assert_eq!(result, 43);