pub trait Pipe<Input>:
Send
+ Sync
+ 'static {
type Output;
// Required method
fn transform(
value: Input,
ctx: &RequestContext,
) -> Result<Self::Output, HttpException>;
}Expand description
Pipe Transform Trait
A transformation pipe transforms input data (such as query parameters or request bodies) into a desired output type. Pipes can also perform validation as part of the transformation.
§Type Parameters
Input: The input type to transform from
§Associated Types
Output: The resulting type after transformation
§Example
struct ParseIntPipe;
impl Pipe<String> for ParseIntPipe {
type Output = i32;
fn transform(value: String, ctx: &RequestContext) -> Result<Self::Output, HttpException> {
value.parse().map_err(|_| HttpException::bad_request("Invalid integer"))
}
}Required Associated Types§
Required Methods§
fn transform( value: Input, ctx: &RequestContext, ) -> Result<Self::Output, HttpException>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.