Skip to content

Commit f9fd468

Browse files
committed
docs: update README to reflect bon migration
- Update lambda-events README with bon builder examples - Fix syntax error in comprehensive-builders example - Highlight key benefits of bon over derive_builder
1 parent fa2af97 commit f9fd468

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

lambda-events/README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ cargo add aws_lambda_events --no-default-features --features apigw,alb
2929

3030
### Builder pattern support
3131

32-
The crate provides an optional `builders` feature that adds builder pattern support for event types. This enables type-safe, immutable construction of event responses without requiring `Default` trait implementations on custom context types.
32+
The crate provides an optional `builders` feature that adds builder pattern support for event types using the [bon](https://crates.io/crates/bon) crate. This enables type-safe, immutable construction of event responses with a clean, ergonomic API.
3333

3434
Enable the builders feature:
3535

@@ -41,7 +41,7 @@ Example using builders with API Gateway custom authorizers:
4141

4242
```rust
4343
use aws_lambda_events::event::apigw::{
44-
ApiGatewayV2CustomAuthorizerSimpleResponseBuilder,
44+
ApiGatewayV2CustomAuthorizerSimpleResponse,
4545
ApiGatewayV2CustomAuthorizerV2Request,
4646
};
4747
use lambda_runtime::{Error, LambdaEvent};
@@ -60,15 +60,21 @@ async fn handler(
6060
permissions: vec!["read".to_string()],
6161
};
6262

63-
let response = ApiGatewayV2CustomAuthorizerSimpleResponseBuilder::default()
63+
let response = ApiGatewayV2CustomAuthorizerSimpleResponse::builder()
6464
.is_authorized(true)
6565
.context(context)
66-
.build()?;
66+
.build();
6767

6868
Ok(response)
6969
}
7070
```
7171

72+
Key benefits of bon builders:
73+
- **Clean API**: `Struct::builder().field().build()` - no `.unwrap()` or `?` needed
74+
- **Automatic Option handling**: Optional fields don't need to be explicitly set
75+
- **Type safety**: Compile-time validation of required fields
76+
- **Ergonomic**: Minimal configuration required
77+
7278
See the [examples directory](https://github.com/aws/aws-lambda-rust-runtime/tree/main/lambda-events/examples) for more builder pattern examples.
7379

7480
## History

lambda-events/examples/comprehensive-builders.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ fn main() {
2828
.secret_id("test-secret".to_string())
2929
.client_request_token("token-123".to_string())
3030
.build();
31-
.unwrap();
3231
}
3332

3433
#[cfg(not(feature = "builders"))]

0 commit comments

Comments
 (0)