Struct Director

Source
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) -> RunResult
where 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 Debug for Director<'_>

Source§

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

Formats the value using the given formatter. Read more

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

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

Source§

fn vzip(self) -> V