[][src]Crate lambda_runtime

Lambda runtime makes it easy to run Rust code inside AWS Lambda. To create Lambda function with this library simply include it as a dependency, make sure that you declare a function that respects the Handler type, and call the start() function from your main method. The executable in your deployment package must be called bootstrap.

#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate lambda_runtime;

use lambda_runtime::error::HandlerError;


#[derive(Deserialize, Clone)]
struct CustomEvent {
    first_name: String,
    last_name: String,
}

#[derive(Serialize, Clone)]
struct CustomOutput {
    message: String,
}

fn main() {
    lambda!(my_handler);
}

fn my_handler(e: CustomEvent, ctx: lambda_runtime::Context) -> Result<CustomOutput, HandlerError> {
    if e.first_name == "" {
        return Err(ctx.new_error("Missing first name!"));
    }
    Ok(CustomOutput{
        message: format!("Hello, {}!", e.first_name),
    })
}

Modules

error

The error module defines the error types that can be returned by custom handlers as well as the runtime itself.

Macros

lambda

Structs

Context

The Lambda function execution context. The values in this struct are populated using the Lambda environment variables and the headers returned by the poll request to the Runtime APIs. A new instance of the Context object is passed to each handler invocation.

Functions

start

Creates a new runtime and begins polling for events using Lambda's Runtime APIs.

Type Definitions

Handler

Functions acting as a handler must conform to this type.