Function lambda_runtime::run
source · [−]pub async fn run<A, B, F>(handler: F) -> Result<(), Error> where
F: Service<LambdaEvent<A>>,
F::Future: Future<Output = Result<B, F::Error>>,
F::Error: Debug + Display,
A: for<'de> Deserialize<'de>,
B: Serialize,
Expand description
Starts the Lambda Rust runtime and begins polling for events on the Lambda Runtime APIs.
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)
}