easy-config-store
A simple, flexible configuration management library for Rust that supports multiple serialization formats and both synchronous and asynchronous operations.
Features
- Support for multiple serialization formats (JSON, TOML, YAML)
- Both synchronous and asynchronous APIs (via Tokio)
- Automatic creation of config files if they don't exist
- Easy updating and reading of configuration
- Transparent access to configuration values via Deref/DerefMut
Installation
Add to your Cargo.toml:
[]
= { = "0.1.0", = ["json"] }
Choose features based on your needs:
json- JSON serialization supporttoml- TOML serialization support (preferred if multiple formats are enabled)yaml- YAML serialization supporttokio- Async support via Tokio
Usage
Basic example
use ConfigStore;
use ;
Async example with Tokio
use ConfigStore;
use ;
async
API Reference
ConfigStore<T>
// Create or read config from a file (sync)
read // Create or read config from a file (async)
async_read.await // Save config to file (sync)
config.save // Save config to file (async)
config.async_save.await // Update from file (sync)
config.update // Update from file (async)
config.async_update.await // Consume the ConfigStore and return the inner config
config.into_inner
Examples
The library includes several examples demonstrating various configurations:
- JSON with standard API: json-std
- JSON with async API: json-async
- TOML with standard API: toml-std
- TOML with async API: toml-async
- YAML with standard API: yaml-std
- YAML with async API: yaml-async
To run an example:
Serialization Format Priority
When multiple serialization format features are enabled, the library prioritizes them in this order:
- TOML
- JSON
- YAML
License
This project is licensed under the MIT License.