Skip to content

Commit 7436632

Browse files
softpropsdavidbarsky
authored andcommitted
update out of date readme doc on runtime handler type (#48)
* update out of date readme doc on runtime handler type * typo
1 parent 26d0ece commit 7436632

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,21 @@ For error reporting to the runtime APIs the library defines the `RuntimeApiError
137137

138138
## lambda-runtime
139139

140-
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 a function that matches the `Handler` type:
140+
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:
141141

142-
```rust,ignore
143-
pub type Handler<E, O> = fn(E, Context) -> Result<O, error::HandlerError>;
142+
```rust
143+
pub trait Handler<E, O> {
144+
/// Run the handler.
145+
fn run(
146+
&mut self,
147+
event: E,
148+
ctx: Context
149+
) -> Result<O, HandlerError>;
150+
}
144151
```
145152

153+
`Handler` provides a default implementation that enables you to provide a Rust closure or function pointer to the `lambda!()` macro.
154+
146155
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)
147156

148157
## AWS event objects

0 commit comments

Comments
 (0)