[][src]Struct automaat_processor_string_regex::StringRegex

pub struct StringRegex {
    pub input: String,
    pub regex: String,
    pub mismatch_error: Option<String>,
    pub replace: Option<String>,
}

The processor configuration.

Fields

input: String

The string that will be matched against the provided regex, and optionally replaced by the replace pattern.

regex: String

The regular expression used to match the input. See the regex crate syntax documentation for more details.

mismatch_error: Option<String>

If the regex pattern does not match the input value, an error is returned. By default, a generic mismatch error is returned.

You can set this value to have it be returned as the error instead.

replace: Option<String>

Optionally use the regex pattern and the input to construct a replacement string to return as this processors output.

You can use variables such as $1 and $2 to match against the patterns in the regex.

Trait Implementations

impl Eq for StringRegex[src]

impl PartialEq<StringRegex> for StringRegex[src]

impl Clone for StringRegex[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for StringRegex[src]

impl<'a> Processor<'a> for StringRegex[src]

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. Read more

type Output = String

The processor can return any (successful) output it wants, as long as that type implements the [std::fmt::Display] trait. Read more

fn validate(&self) -> Result<(), Self::Error>[src]

Validate that the provided regex pattern is valid.

Errors

If the regex syntax is invalid, the Error::Syntax error variant is returned.

If the regex pattern is too big (highly unlikely), the Error::CompiledTooBig error variant is returned.

Both variants wrap the original Regex crate errors.

fn run(&self, _context: &Context) -> Result<Option<Self::Output>, Self::Error>[src]

Do a regex match (and replace), based on the processor configuration.

Output

If replace is set to None, the output of the processor will be Ok(None) if no error occurred.

If replace is set to Some, then Some is returned, matching the final replaced output value in Processor::Output.

Errors

If the regex pattern does not match the input input, the Error::Match error variant is returned. If mismatch_error is set, the error will contain the provided message. If not, a default message is provided.

If the regex pattern is invalid, the same errors are returned as validate.

impl<'de> Deserialize<'de> for StringRegex[src]

impl Serialize for StringRegex[src]

Auto Trait Implementations

impl Send for StringRegex

impl Sync for StringRegex

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]