pub struct PromptMonitor { /* private fields */ }Expand description
File system monitor for detecting PROMPT.md deletion events.
The monitor watches for deletion events and automatically restores PROMPT.md from backup when detected. Monitoring happens in a background thread, so the main thread is not blocked.
§Example
let mut monitor = PromptMonitor::new().unwrap();
monitor.start().unwrap();
// ... run pipeline phases ...
// Check if any restoration occurred
if monitor.check_and_restore() {
println!("PROMPT.md was restored!");
}
monitor.stop();Implementations§
Source§impl PromptMonitor
impl PromptMonitor
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Create a new file system monitor for PROMPT.md.
Returns an error if the current directory cannot be accessed or if PROMPT.md doesn’t exist (we need to know what to watch for).
Sourcepub fn start(&mut self) -> Result<()>
pub fn start(&mut self) -> Result<()>
Start monitoring PROMPT.md for deletion events.
This spawns a background thread that watches for file system events. Returns immediately; monitoring happens asynchronously.
The monitor will automatically restore PROMPT.md from backup if deletion is detected.
Sourcepub fn check_and_restore(&self) -> bool
pub fn check_and_restore(&self) -> bool
Check if any restoration events were detected and reset the flag.
Returns true if PROMPT.md was deleted and restored since the last check. This is a one-time check - the flag is reset after reading.
§Example
// After running some agent code
if monitor.check_and_restore() {
println!("PROMPT.md was restored during this phase!");
}Trait Implementations§
Auto Trait Implementations§
impl Freeze for PromptMonitor
impl !RefUnwindSafe for PromptMonitor
impl Send for PromptMonitor
impl Sync for PromptMonitor
impl Unpin for PromptMonitor
impl !UnwindSafe for PromptMonitor
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more