Skip to content
Prev Previous commit
Next Next commit
Update README
  • Loading branch information
illicitonion committed Jan 6, 2019
commit 3aa5a853e47569af0168057d87cbc36bffd90117
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,18 +174,21 @@ For error reporting to the runtime APIs the library defines the `RuntimeApiError
This library makes it easy to create Rust executables for AWS lambda. The library defines a `lambda!()` macro. Call the `lambda!()` macro from your main method with an implementation the `Handler` type:

```rust
pub trait Handler<E, O> {
pub trait Handler<E, O>: Send {
/// Future of return value returned by handler.
type Future: Future<Item=O, Error=HandlerError> + Send;
/// IntoFuture of return value returned by handler.
type IntoFuture: IntoFuture<Future=Self::Future, Item=O, Error=HandlerError> + Send;

/// Run the handler.
fn run(
&mut self,
event: E,
ctx: Context
) -> Result<O, HandlerError>;
fn run(&mut self, event: E, ctx: Context) -> Self::IntoFuture;
}
```

`Handler` provides a default implementation that enables you to provide a Rust closure or function pointer to the `lambda!()` macro.

If your handler is synchronous, you can just return a `Result` from it; if your handler is asynchronous, you can return a `Future` from it.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for these docs! Small phrasing nit—I'd prefer avoiding using “just” in documentation. I'd instead emphasize that due to the IntoFuture implementation on Result, most synchronous handlers won't need to make any code changes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rephrased


Optionally, you can pass your own instance of Tokio runtime to the `lambda!()` macro. See our [`with_custom_runtime.rs` example](https://github.com/awslabs/aws-lambda-rust-runtime/tree/master/lambda-runtime/examples/with_custom_runtime.rs)

## AWS event objects
Expand Down