fmtstruct 0.2.3

Format-agnostic configuration loader supporting no_std, alloc, and std.
Documentation

Fmtstruct

Format-agnostic configuration loader supporting no_std, alloc, and std.

fmtstruct provides a flexible, compile-time or runtime-extensible interface for loading and parsing configuration files from various sources (Memory, FileSystem) into Rust structs, with optional validation and preprocessing hooks.

Features

  • Format Agnostic: Support for multiple formats (JSON, TOML, YAML, Postcard) via feature flags.
  • Flexible Loading:
    • StaticLoader: Zero-cost abstraction for compile-time defined source/format pairs.
    • DynLoader: Runtime automatic format detection and dynamic dispatch.
  • Source Abstraction:
    • MemorySource: Useful for testing or embedded no_std environments.
    • FileSource: Secure file system access with sandbox protection against path traversal.
  • Advanced Lifecycle:
    • PreProcess: Hooks for data normalization or context injection before validation.
    • ValidateConfig: Optional integration with the validator crate for struct validation.
  • Environment Support: designed for no_std, alloc, and std environments seamlessly.

Usage Examples

Check the examples directory for runnable code:

Installation

[dependencies]
fmtstruct = { version = "0.2", features = ["full"] }

License

Released under the MIT License © 2026 Canmi