pub struct Reloading<T> { /* private fields */ }Expand description
Given a Path from the user, provides a utility that reloads the file
at the path whenever the file is updated
- Use
Reloading::getto get the file contents at a given moment - Use
Reloading::receiverto get a tokiowatch::Receiver
§Example
use clap::Parser;
use clap_adapters::prelude::*;
#[derive(Debug, Parser)]
struct Cli {
/// Path to a Json config that's reloaded
#[clap(long)]
config: Reloading<PathTo<JsonOf<serde_json::Value>>>,
}
let cli = Cli::parse_from(["app", "--config=./config.json"]);
let current_config = cli.config.get();
let config_rx = cli.config.receiver();Note:
Reloadingis powered bynotify, which has some known problems, so check out the caveats if you run into trouble
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Reloading<T>
impl<T> RefUnwindSafe for Reloading<T>
impl<T> Send for Reloading<T>
impl<T> Sync for Reloading<T>
impl<T> Unpin for Reloading<T>
impl<T> UnwindSafe for Reloading<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more