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>>, F::Future: Future<Output = Result<R, F::Error>>, F::Error: Debug + Display, 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.

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)
}