Watchfile
A simple trait that will watch a (serializable) file for changes and update a data struct.
Uses tokio for async file reading and tokio::sync::watch for notifying about changes.
File types / Features
Currently supported:
- JSON (
features = ["json"]usingserde_json) - TOML (
features = ["toml"]usingtoml) - YAML (
features = ["yaml"]usingserde_yaml)
All of them are optional features, all enabled by default. To minimize dependencies, you can disable them by using default-features = false in your Cargo.toml, and then enabling only the ones you need (for example, only JSON):
[]
= { = "0.1", = false, = ["json"] }
Usage:
use Duration;
use WatchFile;
use Deref;
async