Function lambda_runtime::run
source · pub async fn run<A, F, R, B, S, D, E>(handler: F) -> Result<(), Error>where
F: Service<LambdaEvent<A>, Response = R>,
F::Future: Future<Output = Result<R, F::Error>>,
F::Error: for<'a> Into<Diagnostic<'a>> + Debug,
A: for<'de> Deserialize<'de>,
R: IntoFunctionResponse<B, S>,
B: Serialize,
S: Stream<Item = Result<D, E>> + Unpin + Send + 'static,
D: Into<Bytes> + Send,
E: Into<Error> + Send + Debug,
Expand description
Starts the Lambda Rust runtime and begins polling for events on the Lambda Runtime APIs.
If you need more control over the runtime and add custom middleware, use the Runtime type directly.
§Example
use lambda_runtime::{Error, service_fn, LambdaEvent};
use serde_json::Value;
#[tokio::main]
async fn main() -> Result<(), Error> {
let func = service_fn(func);
lambda_runtime::run(func).await?;
Ok(())
}
async fn func(event: LambdaEvent<Value>) -> Result<Value, Error> {
Ok(event.payload)
}