pub struct FileWatcherConfig<T, E> {
pub log_name: String,
pub file: PathBuf,
pub parser: Arc<dyn Fn(Vec<u8>) -> Result<T, E> + Send + Sync>,
pub retry_interval: Duration,
}
Expand description
really-notify
primary input.
[T
] is the target parse type, i.e. your serde-deserializable Config
struct.
[E
] is the generic error type that your parser can fail with.
Fields§
§log_name: String
Cosmetic, used for logs to be consistent with application terminology
file: PathBuf
Path to the file you are interested in changes of. Do your worse with symlinks here.
parser: Arc<dyn Fn(Vec<u8>) -> Result<T, E> + Send + Sync>
Parser function to transform a modified target file into our desired output. If you just want raw bytes, you can pass it through, or not set this at all.
retry_interval: Duration
Defaults to one second, how often to attempt reparsing/error recovery.
Implementations§
Source§impl FileWatcherConfig<Vec<u8>, Infallible>
impl FileWatcherConfig<Vec<u8>, Infallible>
Source§impl<T: Send + 'static, E: Display + Send + 'static> FileWatcherConfig<T, E>
impl<T: Send + 'static, E: Display + Send + 'static> FileWatcherConfig<T, E>
Sourcepub fn with_parser<T2: Send + 'static, E2: Display + Send + 'static>(
self,
func: impl Fn(Vec<u8>) -> Result<T2, E2> + Send + Sync + 'static,
) -> FileWatcherConfig<T2, E2>
pub fn with_parser<T2: Send + 'static, E2: Display + Send + 'static>( self, func: impl Fn(Vec<u8>) -> Result<T2, E2> + Send + Sync + 'static, ) -> FileWatcherConfig<T2, E2>
Set a new parser and adjust the FileWatcherConfig type parameters as needed.
Sourcepub fn with_retry_interval(self, retry_interval: Duration) -> Self
pub fn with_retry_interval(self, retry_interval: Duration) -> Self
Set an alternative retry_interval
Auto Trait Implementations§
impl<T, E> Freeze for FileWatcherConfig<T, E>
impl<T, E> !RefUnwindSafe for FileWatcherConfig<T, E>
impl<T, E> Send for FileWatcherConfig<T, E>
impl<T, E> Sync for FileWatcherConfig<T, E>
impl<T, E> Unpin for FileWatcherConfig<T, E>
impl<T, E> !UnwindSafe for FileWatcherConfig<T, E>
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