[−][src]Trait automaat_core::Processor
The main trait to implement when creating a new Automaat processor.
Implementing the Processor
trait makes it possible to use that processor
in the automaat-server
application.
Associated Types
type Error: Error
If a processor fails its intended purpose, the returned error is turned
into a string, and shown in the automaat-web-client
application.
type Output: Display
The processor can return any (successful) output it wants, as long as
that type implements the std::fmt::Display
trait.
In the automaat-server
application, the output is turned into a
string, and is processed as markdown.
While not required, it's best-practice to take advantage of this fact, to format the output in a pleasant way for users.
Associated Constants
const NAME: &'static str
The human-formatted name of the processor, used to visually identify this processor amongst others.
Required methods
fn run(&self, context: &Context) -> Result<Option<Self::Output>, Self::Error>
Actually runs the pipeline, performing whatever side-effects are defined in this specific processor.
The Context
object can be used to access a temporary workspace
directory that is shared across all processors using the same context
object.
Errors
When a processor has run to completion, it is supposed to return
whatever valuable information could be used via Self::Output
. If an
unexpected result occurred, Self::Error
should be returned.
Provided methods
fn validate(&self) -> Result<(), Self::Error>
The validate
method is used by the automaat-server
application to do
a runtime check to make sure that the processor is correctly configured
before running it.
This is an additional validation, on top of whatever invariant is guaranteed using the type system.
The default implementation of this method always returns Ok
.
Errors
If validation fails, an error should be returned. The error message can
be used by clients such as automaat-web-client
to show an informative
message to the user.