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>

source

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.

source

pub fn add_handler<K>( &mut self, kind: K, handler: &'a dyn Handler ) -> Result<(), DirectorError>where K: Into<String>,

Add a handler for jobs labeled as kind.

source

pub async fn run<P>(&self, path: P) -> RunResultwhere P: AsRef<Path>,

Handle a path.

Returns whether the path is a stream terminator or not.

source

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.

source

pub fn watch_directory(&self, path: &Path) -> Result<RunResult, DirectorError>

Watch a directory and act on the paths within it.

source

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§

source§

impl<'a> Debug for Director<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V