pub struct Director<'a> { /* private fields */ }
Expand description
Dispatch jobs to registered handlers.
Jobs are sorted into accept
, reject
, and fail
directories based on whether they were
accepted by the relevant handler. Once handled, a .stamp
file containing the timestamp of
when the job was completed is created beside the final location. In addition, rejected and
failed jobs have a .reason
file describing what happened.
Implementations§
Source§impl<'a> Director<'a>
impl<'a> Director<'a>
Sourcepub fn new(root: &Path) -> Result<Self, DirectorError>
pub fn new(root: &Path) -> Result<Self, DirectorError>
Creates a new Director
.
The accept
and reject
directories are created as children of the given directory.
Sourcepub fn add_handler<K>(
&mut self,
kind: K,
handler: &'a dyn Handler,
) -> Result<(), DirectorError>
pub fn add_handler<K>( &mut self, kind: K, handler: &'a dyn Handler, ) -> Result<(), DirectorError>
Add a handler for jobs labeled as kind
.
Sourcepub async fn run<P>(&self, path: P) -> RunResult
pub async fn run<P>(&self, path: P) -> RunResult
Handle a path.
Returns whether the path is a stream terminator or not.
Sourcepub fn path_stream(
&self,
path: &Path,
) -> Result<impl Stream<Item = PathBuf>, DirectorError>
pub fn path_stream( &self, path: &Path, ) -> Result<impl Stream<Item = PathBuf>, DirectorError>
Return a stream of paths to act on.
The beginning of the stream will contain paths which exist at startup and afterwards, paths for which “important” events occur will be generated.
Sourcepub fn watch_directory(&self, path: &Path) -> Result<RunResult, DirectorError>
pub fn watch_directory(&self, path: &Path) -> Result<RunResult, DirectorError>
Watch a directory and act on the paths within it.
Sourcepub async fn watch_directory_in(
&self,
path: &Path,
) -> Result<RunResult, DirectorError>
pub async fn watch_directory_in( &self, path: &Path, ) -> Result<RunResult, DirectorError>
Watch a directory and act on the paths within it on an existing runtime.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Director<'a>
impl<'a> !RefUnwindSafe for Director<'a>
impl<'a> !Send for Director<'a>
impl<'a> !Sync for Director<'a>
impl<'a> Unpin for Director<'a>
impl<'a> !UnwindSafe for Director<'a>
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