pub trait RequestResponse<I, O>: Provider{
// Required method
fn execute<'life0, 'async_trait>(
&'life0 self,
input: I,
) -> Pin<Box<dyn Future<Output = Result<O, AppError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
}Expand description
Unary request → single response (HTTP POST, gRPC unary, DB query).
§Example
use rskit_errors::AppResult;
use rskit_provider::{Provider, RequestResponse};
struct Echo;
impl Provider for Echo {
fn name(&self) -> &'static str {
"echo"
}
}
#[async_trait::async_trait]
impl RequestResponse<String, String> for Echo {
async fn execute(&self, input: String) -> AppResult<String> {
Ok(input.to_uppercase())
}
}
let response = Echo.execute("hello".to_string()).await?;
assert_eq!(response, "HELLO");Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".