Module preprocessors

Source
Expand description

List of all the preprocessors that mutates the given field, including changing the type if required. A list of all the preprocessors that preprocess the given field, mutating it if required. The type of the field may be changed. For example, the lowercase preprocessor will change the type of the field to String.

§Lowercase

The lowercase preprocessor converts all the characters in the given value to lowercase using the to_lowercase method.

§Usage

#[preprocess::sync]
pub struct MyStruct {
    #[preprocess(lowercase)]
    pub my_string: String,
}

§Uppercase

The uppercase preprocessor converts all the characters in the given value to uppercase using the to_uppercase method.

§Usage

#[preprocess::sync]
pub struct MyStruct {
    #[preprocess(uppercase)]
    pub my_string: String,
}

§Trim

The trim preprocessor trims the given value using the trim method.

§Usage

#[preprocess::sync]
pub struct MyStruct {
    #[preprocess(trim)]
    pub my_string: String,
}

Functions§

preprocess_lowercase
Preprocesses the given string and converts it to lowercase using the to_lowercase method. Returns a Cow<’a, str> to avoid unnecessary allocations.
preprocess_trim
Preprocesses the given string and removes all leading and trailing whitespaces. Returns a Cow<’a, str> to avoid unnecessary allocations.
preprocess_uppercase
Preprocesses the given string and converts it to uppercase using the to_uppercase method. Returns a Cow<’a, str> to avoid unnecessary allocations.